Android Project Template

Hi guys,

I’ve been trying to figure out a clean way to setup Android project. I don’t really want to modify sample and continue the development inside Urho folders. An out of Urho/using Urho as a library (AAR for Android) approach is preferred. Currently, on Windows, I have a very clean CMake based project structure working, however, I wonder if there is any Android example that I could follow.

Edit: BTW, I have studied some CMake, Gradle, NDK, etc. No progress yet.



This is my HelloWorld project that I used to figure out how to work on Android

HelloWorld and Urho3D

Here is my CMakeLists.txt -

# Set CMake minimum version and CMake policy required by UrhoCommon module
cmake_minimum_required (VERSION 3.10.2)
if (COMMAND cmake_policy)
    # Libraries linked via full path no longer produce linker search paths
    cmake_policy (SET CMP0003 NEW)
    # INTERFACE_LINK_LIBRARIES defines the link interface
    cmake_policy (SET CMP0022 NEW)
    # Disallow use of the LOCATION target property - so we set to OLD as we still need it
    cmake_policy (SET CMP0026 OLD)
    # MACOSX_RPATH is enabled by default
    cmake_policy (SET CMP0042 NEW)
    # Honor the visibility properties for SHARED target types only
    cmake_policy (SET CMP0063 OLD)
endif ()

# Set project name
project (HelloWorld)
# Set CMake modules search path
# Include UrhoCommon.cmake module after setting project name
include (UrhoCommon)
# Define target name
set (TARGET_NAME HelloWorld)

define_source_files (



define_resource_dirs ()

setup_main_executable ()

I tried hard, but no result on Android at all.

What the errors are?

I also had this dilemma in our Android project. There is one sample project template here
If I remember correctly we had issues between Kotlin, Gradle, and Android studio they didn’t seem to like each other version numbers or something. Probably the real reason why I did not succeed was that I am a complete noob. :sweat_smile:
What we ended up doing is that we worked normally in project scaffolding way and when it was time to build to android we edited our main.cpp so that it would be similar to samples.

I hope this helps you forward in your quest. If you figure this thing out plz let me know. :blush:

Maybe you can find answer here

Thank you GastaGaming! I think they are not using AAR or “out of Urho folder”. But I’m studying them hard.

@johnnycable there are too many issues, I cannot say which piece I missed, when I’m still trying to put the puzzle together.

The whole building system of Urho3D is complicated, people need to know the implementation details to work on different platforms. I don’t know it is common or we just need more documents on these topics. It seems that we need some start point / template/ sample / wizard, to make our code run first.

Since I’m not alone, so I hope I can make it work and post my steps / example here.

1 Like

Before the AAR there is no easy way to use Urho3D as library in Android build. And, even the Rake scaffolding task that we provide does not support Android build. With AAR I see there is a chance to pull this off. YMMV.

1 Like

I wonder if these AARs can work since they are too small (after excluding the “assets”), the main parts are in the *.so files. In other words, dynamic libraries are used.

I have tried setting URHO3D_LIB_TYPE to STATIC (-DURHO3D_LIB_TYPE=STATIC, according to document, it’s actually the default) and passing it to gradle, but it does not work.


1 Like

The whole Gradle + CMake + Android Studio for NDK thing is horrible. Weekend ends now, still no progress.

We publish AAR at bintray here like ay other maven artifacts out there.

This week I hope I can crank a windows pc open, so I can test this thing. Today just it took 3 hours to create a bootable usb… :grimacing: :grimacing: :grimacing:

IMHO, It’s not a Windows specific issue.

Uploaded the testing project -

Hi weitjong,

I found that in the AAR I build, there is no “tree” folder, and from bintray you linked, there is this folder in the archive. I find it is the reason why the AARs I built were very small.
Do you know the cause of the problem?



You didn’t provide any information on the errors/warnings, if any, on the build process. As such, my guess on what has happened is as good as yours and anyone else. All the steps taken by CI to build and publish the AAR to Bintray is reproducible. If you cannot get same result with the same steps then It may be host machine or build environment issue. The steps are not verified yet on Windows host so far, AFAIK. Ideally it should just work since it is Java based.

Hi guys,

I have solved most of the issues and got a clean project structure for Android building!


1. The project refers Urho3D as a parallel project and reuses most of the stuff from Urho3D, just like a real library, except for CMake folder. (we can also use soft link to reuse CMake folder of Urho3D)


2. Everything Android related is put in `android’ folder, no pollution to project’s root folder.

3. Android Studio also works


4. Known issue - we have to copy CoreData, Data etc. folders into launcher-app\src\main\assets folder just like Urho3D.

Thanks to all who kindly help me out @weitjong, @Pencheff and others in this forum.

It is not perfect as I wanted, and can be surely cleaned up further. But since it is a good start point so I post it here. I know nothing about Android so please improve it if you are interested.


I have also written my own Android Template project , also solved issue #4.

You can take look at it and see if it’s relevant to your solution .

The copy Data/CoreDT procedure is done in the link below , line 48


Thank you! @elix22! Your solution to the data folders is great. Will these data folders be deleted when we clean the project?

For people who want to change project directory and make folders a little cleaner, the following code in settings.gradle.kts is the key -

include(":urho3d-lib", ":launcher-app")
project(":urho3d-lib").projectDir = File(settingsDir, "../../Urho3D/android/urho3d-lib")
1 Like

No , but it will overwrite modified resources in the next build


I met another issue -
In the Visual Studio solution CMake generated, Urho3D project is not included, this leads issues for code referencing and debugging.


How can we add Urho3D project into the solution?


Can you just add the Urho .sln manually?