Android Project Template

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.

image

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?

image

Thanks,
Kai

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!

image

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)

folder_structure

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

image
3. Android Studio also works

image

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.

4 Likes

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

3 Likes

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

2 Likes

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

image

How can we add Urho3D project into the solution?

Thanks!

Can you just add the Urho .sln manually?

CMake will restore my VS solution if I rebuild the VS solution, which makes the added Urho3D project deleted.

I think the ‘right’ solution might be adding the Urho project as a subproject or something like that (which I don’t think the build system supports at present). As a workaround, you could try something like this:

There may be better ways than this, but I know almost nothing about VS and not that much about CMake.

1 Like

I am a little bit confuse now. Are you doing your Android build using Visual Studio now? Or, this is just another general question on how to use Urho3D library as external library?

Hi Weitjong,

Thanks for asking! Yes, I agree the last question about VS is a little off topic. However, the cmake testing template is supposed to be multi-platform.

I have solved building apk in Android Studio, and I just wanted to improve the exe build on Visual Studio on Windows.

@SirNate0 the INCLUDE_EXTERNAL_MSPROJECT surely works for Visual Studio. Thank you very much!

1 Like

Since this is off topic and I am also not familiar with VS, I will keep my comment short. The latest release of VS has a some-what working CMake integration in the IDE itself. This new approach does away with generate-solution-file-then-open-solution-file steps all together. Just open the root project containing the CMakeLists.txt. This is how Clion IDE from JetBrains works by the way. In the root CMakeList.txt you can nest other lib projects with their own (root) CMakeLists.txt.

1 Like

I confirm. I recently moved to windows and I did like @weitjong said. I used vs community 2019. You just need to open cmake file and configure things a bit here and there. The process is guided and cmake is supported well enough.

1 Like