Urho3D in Android Studio on Windows

I’ve spend a lot of time try to sort out all the issues and build Urho3D using Android Studio on Windows 10, a lot of issues occur.

I think it’s better to create a new thread here, so it would be clearer and may help other people as well.

If you know something about Android Studio + Windows, please give me a hand.

Thanks!

I am very sorry to hear that. I really want to help. I have tried to install Windows 10 using the ISO download provided by Microsoft to my new rig one or two months ago, however, I gave up after numerous attempts. My new rig does not have DVD/Bluray drive anymore and somehow I could not get the Linux tool to “burn” the ISO properly to my USB drive. So, until I solve my Windows 10 installation issue, I cannot do much to help you guys on that side of the digital divide.

p.s. I have a valid Win7 license key, which some suggested can be used to activate the Win10. But I have not really reached that point.

I understand, you’ve already done a lot.

I think I can just paste my issues, if someone know the possible answer, it would be solvable.

My #1 issue -

CMake Error at D:/code/man/Urho3D/CMake/Modules/FindUrho3D.cmake:343 (message):
Could NOT find compatible Urho3D library in Urho3D SDK installation or
build tree or in Android library. Use URHO3D_HOME environment variable or
build option to specify the location of the non-default SDK installation or
build tree. For Android platform, double check if you have specified to
use the same ANDROID_ABI as the Urho3D Android Library, especially when you
are not using universal AAR.
Call Stack (most recent call first):
D:/code/man/Urho3D/CMake/Modules/UrhoCommon.cmake:244 (find_package)
CMakeLists.txt:45 (include)

1 Like

My #2 issue - SOLVED after I installed MinGW

Steps

  1. Download from http://www.mingw.org/
  2. Install MinGW Installation Manager
  3. Check & Install (Apply Changes from the menu) components as
  4. Add execute folders to path (Environment variable)
    image

CMake Error at D:\code\man\Urho3D\CMake\Modules\CheckCompilerToolchain.cmake:162 (message):
Could not find native compiler toolchain. This is usually caused by wrong
PATH env-var value.

CMake Warning (dev) in CMakeLists.txt:

No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as

 project(ProjectName)

near the top of the file, but after cmake_minimum_required().

CMake is pretending there is a “project(Project)” command on the first
line.

This warning is for project developers. Use -Wno-dev to suppress it.

CMake Error in CMakeLists.txt:

No CMAKE_C_COMPILER could be found.

Tell CMake where to find the compiler by setting either the environment
variable “CC” or the CMake cache entry CMAKE_C_COMPILER to the full path to
the compiler, or to the compiler name if it is in the PATH.

CMake Error in CMakeLists.txt:

No CMAKE_CXX_COMPILER could be found.

Tell CMake where to find the compiler by setting either the environment
variable “CXX” or the CMake cache entry CMAKE_CXX_COMPILER to the full path
to the compiler, or to the compiler name if it is in the PATH.

Call Stack (most recent call first):
Source/Urho3D/CMakeLists.txt:210 (check_native_compiler_exist)

1 Like

My #3 issue - SOLVED by change compiler options in the Android Studio Settings


How can I control build options in Android Studio?

According to

"The Gradle properties can be passed by using “-P” Gradle option, e.g.: “./gradlew -P URHO3D_LUA=0 build” to build without Lua subsystem."

I have tested with gradlew.bat, with -P parameters, it works, how can I achieve same in Android Studio?

Did you take a look at this?

About 50%… apology for the lack of Android development knowledge.

Are you trying to build the library or use the library? Your first issue indicates the latter. Does that mean building part is already successfully done on Win10?

I’m building urho itself by open urho directory by Android Studio. I have built it by gradlew command line, I’m not sure if it will affect the Android Studio result. The configuration is success and the #1 issue disappeared later. Now I’m stuck with #3.

My #4 issue- Adding -P URHO3D_WEBP=0 for the compiling option will disable WebP, but it is not the solution.

FAILED: Source/ThirdParty/WebP/CMakeFiles/WebP.dir/src/dsp/cpu.c.o
D:\AndroidDev\AndroidSDK\ndk\21.0.6113669\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=armv7-none-linux-androideabi17 --gcc-toolchain=D:/AndroidDev/AndroidSDK/ndk/21.0.6113669/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=D:/AndroidDev/AndroidSDK/ndk/21.0.6113669/toolchains/llvm/prebuilt/windows-x86_64/sysroot -DURHO3D_ANGELSCRIPT -DURHO3D_FILEWATCHER -DURHO3D_IK -DURHO3D_LOGGING -DURHO3D_NAVIGATION -DURHO3D_NETWORK -DURHO3D_PHYSICS -DURHO3D_PROFILING -DURHO3D_STATIC_DEFINE -DURHO3D_THREADING -DURHO3D_URHO2D -DURHO3D_WEBP -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -Qunused-arguments -fcolor-diagnostics -Wno-argument-outside-range -O0 -fno-limit-debug-info -fPIC -MD -MT Source/ThirdParty/WebP/CMakeFiles/WebP.dir/src/dsp/cpu.c.o -MF Source\ThirdParty\WebP\CMakeFiles\WebP.dir\src\dsp\cpu.c.o.d -o Source/ThirdParty/WebP/CMakeFiles/WebP.dir/src/dsp/cpu.c.o -c …/…/…/…/…/…/Source/ThirdParty/WebP/src/dsp/cpu.c
…/…/…/…/…/…/Source/ThirdParty/WebP/src/dsp/cpu.c:22:10: fatal error: ‘cpu-features.h’ file not found
#include <cpu-features.h>
^~~~~~~~~~~~~~~~
1 error generated.

It is an error compiling WebP related code.

Definitely many places can be optimized but Samples of Urho3D now can run and be debugged. Physical phone also runs.

The default size of urho app is really big, storage of an emulater can be changed -

2 Likes

Good to know you are making progress.

For the app size, I assume your build was debug build so it’s expected to be big

Yes. also IMO, there are other reasons.

  1. ANDROID_ABI can be used, currently it is universal -
    image

  2. I also guess this should be used -

Your last issue is reproducible when using latest SDK. Last night I hit by this too after upgrading my Android SDK in my dockerized build environment. But it was late so I didn’t look into it deeper yet.

We provide build option for Gradle Android build to allow user to choose which ABI to be built. Our default is the default of Android plugin for Gradle provided by Google.

1 Like

Yes, you are right. I checked the document. We can copy all cmake scripts and stuff and start a new project, using Urho3D as library. However, I have not figured out yet how to setup an project for Android, with all these android related scripts.

I will bump the version of some dependencies for Android build and modify the Gradle build script to work with latest Android SDK/NDK. I expect building of Urho3D library to work out of the box via CLI or IDE (IntelliJ and Android Studio, they internally invoke the same Gradle process anyway). Well, until newer SDK/NDK breaks it again.

As for using Urho3D as (Android) library with Gradle as the build system, you will have to learn how to use AAR. When I migrated the build system from Ant to Gradle, I have decided to go all the way to publish our AAR to a public repository and that downstream project should be able to easily setup to use Urho3D library as one of the project dependency. However, I dropped the ball somewhere and I haven’t got time to finish what I have started. The AAR is already published by the CI automatically. See https://bintray.com/bintray/jcenter?filterByPkgName=urho3d-lib

Edit: the culprit was NDK 21.0.x. As a quick fix I configure the build script to use NDK 20.1.5948944, so I can move on for other changes. It means user will have to install Android NDK side by side with the right version and not the (deprecated) Android NDK-bundle anymore.

Edit2: after further investigation I actually did not find anything unusual in the NDK 21.0.6113669 as compared to NDK 20.1.5948944 in respect to cpu-features. Long story short, I have to adjust the build script so that it works for both versions now. In fact now I actually not sure how it worked in the past without the adjustment. Anyway…

3 Likes

The latest master branch works out of the box for Android Studio 3.5 now (tested on Linux host system). That’s the good news. The bad news is, all the Lua samples do not work anymore via Urho3DPlayer because of FORTIFY check. I did’t see this before using previous SDK. I know it is off-topic but I think you may want to know in case you re-enable Lua subsystem again in your build.

A/libc: FORTIFY: strchr: prevented read past end of buffer
    Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 6545 (SDLThread), pid 6443 (SDLActivity)

Edit: with LuaJIT, on the other hand, all the samples pass the test with flying colors.

3 Likes

Thank you @weitjong you are the best! I will find another day to try the new one and figure out how to build Urho as a library. Thank you again for the quick response and help!

1 Like