Android SDK And NDK Troubleshooting

1. Compilation errors "Trying to use a unit which was compiled with a different FPU mode"

This indicates you compiled FPC standard units without -CfVFPV3. This would result in very slow execution on Android. Solutions:

  • If you compiled FPC cross-compiler manually remember to add CROSSOPT="-CfVFPV3" .

  • If you compile FPC cross-compiler by fpcupdeluxe, go to the "Setup+" options and for Android/Arm add -CfVFPV3 option.

FpcUpDeluxe cross-compiler options

We recommend to install FPC cross-compilers for Android using latest fpcupdeluxe which will make it good out-of-the-box.

2. libz errors, "exception in thread png-cruncher" errors

In case of errors about libz.so.1 (resulting in later errors about Exception in thread "png-cruncher…​) on Linux 64-bit, see here: http://stackoverflow.com/questions/29241640/error-unable-to-run-mksdcard-sdk-tool . Install additional libraries as needed.

3. clang errors

The Android NDK for 32-bit Windows has a known error in version r12b, see https://github.com/android-ndk/ndk/issues/139 . The clang binaries are for 64-bit architecture. It will prevent compiling the NDK samples (not related to CGE…​). This should be fixed in next NDK release. An easy fix for now is to go to "ndk\toolchains\llvm\prebuilt\windows\bin" directory and:

  • rename clang.exe -> clang_64.exe (or just remove it)

  • rename clang_32.exe -> clang.exe

  • rename clang++.exe -> clang++_64.exe (or just remove it)

  • copy clang.exe -> clang++.exe (yes, just copy to a new name, this is the same executable).

4. "Could not find tools.jar" error

The error Could not find tools.jar usually means you did not set JAVA_HOME correctly (to point to JDK).

5. Errors when executing aidl on 64-bit (x86_64) Linux

If you get errors when executing /usr/local/android/android-sdk-linux/build-tools/23.0.2/aidl on 64-bit (x86_64) Linux:

That is because Google distributes them as compiled for a 32-bit (i386) Linux system. Install some additional libraries to make them work. On Debian:

apt-get install libc6-i386 lib32stdc++6 lib32z1

(In general, old build-tools are distributed only for Linux 32-bit, and new build-tools are distributed only for Linux 64-bit. Google doesn’t provide alternatives for both architectures here.) See https://stackoverflow.com/questions/24158727/android-sdk-aapt-error-libstdc-so-6-cannot-open-shared-object-file .


To improve this documentation just edit this page and create a pull request to cge-www repository.