"lime build android" results in "fatal error: 'typeinfo' file not found"
-
After following the Getting Started guide, creating a simple project via the command
flixel tpl -n "HelloWorld"
,.and then setting up Android via thelime setup android
command, as per the Android guide, I still could not build for Android via the commandlime build android
, because I would get the following error message:$ lime build android
Creating /Library/WebServer/Documents/stomp/game/HelloWorld/export/android/obj/obj/android-v7/__pch/haxe/hxcpp.h.gch...
clang++: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang++: warning: optimization flag '-finline-limit=10000' is not supported [-Wignored-optimization-argument]
clang++: warning: argument unused during compilation: '-Wa,--noexecstack' [-Wunused-command-line-argument]
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
/usr/local/lib/haxe/lib/hxcpp/4,0,4/include/hxcpp.h:19:13: fatal error: 'typeinfo' file not found
#include <typeinfo>
^~~~~~~~~~
1 warning and 1 error generated.
Error: Could not create PCHWhen I asked about this in the Haxe Discord channel, @dean said:
which android ndk are you using? AFAIK r15c is the most recent version to work with openfl right now.
you need to downgrade the NDK to r15c
you can get the older versions here https://developer.android.com/ndk/downloads/older_releasesI downloaded the ~1 year out-dated NDK as per @dean's suggestion, and re-ran
lime setup android
to re-point to this older NDK.Then I tried building again...
$ lime build android Creating /Library/WebServer/Documents/stomp/game/HelloWorld/export/android/obj/obj/android-v7/__pch/haxe/hxcpp.h.gch... Compiling group: haxe arm-linux-androideabi-g++ -Iinclude --sysroot=/Users/Joncom/Library/Android/sdk/ndk-bundle-r15c/platforms/android-14/arch-arm -I/Users/Joncom/Library/Android/sdk/ndk-bundle-r15c/sources/cxx-stl/gnu-libstdc++/4.9/include -I/Users/Joncom/Library/Android/sdk/ndk-bundle-r15c/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include -DHXCPP_ARMV7 -DHXCPP_VISIT_ALLOCS(haxe) -DHXCPP_API_LEVEL=331(haxe) -I/usr/local/lib/haxe/lib/hxcpp/4,0,4/include -Iinclude -fpic -fvisibility=hidden -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -Wno-overflow -D_LINUX_STDDEF_H -Wno-psabi -DHXCPP_CPP11 -DHXCPP_ARMV7 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fomit-frame-pointer -fexceptions -fno-strict-aliasing -finline-limit=10000 -DANDROID=ANDROID -DHX_ANDROID -DHXCPP_ANDROID_PLATFORM=14 -Wa,--noexecstack -O2 -DNDEBUG -c ... tags=[haxe,static] - src/sys/io/_Process/Stdout.cpp - src/sys/io/Process.cpp - src/sys/io/_Process/Stdin.cpp - src/sys/io/FileOutput.cpp - src/sys/io/File.cpp - src/sys/FileSystem.cpp - src/haxe/lang/Iterable.cpp - src/haxe/lang/Iterator.cpp ... blah blah blah
Success, it worked. Just wanted to say thanks @dean, and also document this here just in case anybody else runs into the same issue (including my future self).
-
Just wanted to continue documenting what I encountered during my attempts to get Android compiling OK:
So, although the C++ issue above was resolved, I quickly encountered a new issue/error:
ERROR: JAVA_HOME is set to an invalid directory: /Users/Joncom/SDKs//java_jdk
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.The strange thing about this issue was that I could
echo $JAVA_HOME
and it looked correct already, and yet the build process thoughtJAVA_HOME
pointed somewhere completely different.$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/HomeThe fix was to comment out this line in
~/.lime/config.xml
:<set name="JAVA_HOME" value="/Users/Joncom/SDKs//java_jdk" />
like so:
<-- <set name="JAVA_HOME" value="/Users/Joncom/SDKs//java_jdk" /> -->
and comment out this line in
~/.hxcpp_config.xml
:<set name="JAVA_HOME" value="${SDK_ROOT}/java_jdk" unless="JAVA_HOME" />
like so:
<!-- <set name="JAVA_HOME" value="${SDK_ROOT}/java_jdk" unless="JAVA_HOME" /> -->
OK, getting closer. Now when I try to build, I get the following:
$ lime build android Creating /Library/WebServer/Documents/stomp/game/HelloWorld/export/android/obj/obj/android-v7/__pch/haxe/hxcpp.h.gch... Compiling group: haxe arm-linux-androideabi-g++ -Iinclude --sysroot=/Users/Joncom/Library/Android/sdk/ndk-bundle-r15c/platforms/android-14/arch-arm -I/Users/Joncom/Library/Android/sdk/ndk-bundle-r15c/sources/cxx-stl/gnu-libstdc++/4.9/include -I/Users/Joncom/Library/Android/sdk/ndk-bundle-r15c/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include -DHXCPP_ARMV7 -DHXCPP_VISIT_ALLOCS(haxe) -DHXCPP_API_LEVEL=331(haxe) -I/usr/local/lib/haxe/lib/hxcpp/4,0,4/include -Iinclude -fpic -fvisibility=hidden -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -Wno-overflow -D_LINUX_STDDEF_H -Wno-psabi -DHXCPP_CPP11 -DHXCPP_ARMV7 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fomit-frame-pointer -fexceptions -fno-strict-aliasing -finline-limit=10000 -DANDROID=ANDROID -DHX_ANDROID -DHXCPP_ANDROID_PLATFORM=14 -Wa,--noexecstack -O2 -DNDEBUG -c ... tags=[haxe,static] - src/lime/utils/AssetCache.cpp [haxe,release] Link: libApplicationMain-v7.so Downloading http://services.gradle.org/distributions/gradle-2.10-bin.zip .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. Unzipping /Users/Joncom/.gradle/wrapper/dists/gradle-2.10-bin/2v0chm5oshw52qn5d7jjz7lo0/gradle-2.10-bin.zip to /Users/Joncom/.gradle/wrapper/dists/gradle-2.10-bin/2v0chm5oshw52qn5d7jjz7lo0 Set executable permissions for: /Users/Joncom/.gradle/wrapper/dists/gradle-2.10-bin/2v0chm5oshw52qn5d7jjz7lo0/gradle-2.10/bin/gradle FAILURE: Build failed with an exception. * What went wrong: A problem occurred configuring project ':app'. > failed to find target with hash string 'android-26' in: /Users/Joncom/Library/Android/sdk * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 1 mins 27.682 secs
There's actually two problems here. The first thing I noticed was that it was telling me to
Set executable permissions for
thegradle
binary it just downloaded/unzipped. I figured I might just need to re-run the command withsudo
.sudo lime build android
Yep. That did it! :)
However, the build still failed, still complaining about:
failed to find target with hash string 'android-26'
Opening "Android Studio", and navigating to
Tools
>SDK Manager
, and installing SDK 26 resolved this issue, and finally build was successful.Thanks to @dean, @Gama11, and @NotBilly (in HaxeFlixel Discord channel) for helping me through this.