Android: make this work again with NDK r19+ and CMake 3.16+.
Also updating the docs to use system 24 instead of 22 as that's the
first version with Vulkan support; plus other random updates and add a
bunch of new troubleshootings.
`CMAKE_ANDROID_STL_TYPE` to use libc++, `CMAKE_SYSTEM_VERSION` to minimal API version level you wish to use and `CMAKE_ANDROID_ARCH_ABI` to target platform
ABI. Check the [CMake Android cross-compiling documentation](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android)
for further information. You can omit specifying `CORRADE_RC_EXECUTABLE` if
@ref building-cross-corrade-rc "natively-built corrade-rc" is accessible
through `PATH`.
@ -1044,26 +1043,31 @@ If you set `CMAKE_INSTALL_PREFIX` to `/usr` subdirectory of the particular
Android platform sysroot, the package will get found automatically when
compiling depending projects. Gradle and other Android buildsystems expect
platform-independent includes and other files to be stored in a central
location, you can set `MAGNUM_INCLUDE_INSTALL_PREFIX` to `/usr` subdirectory of
the global NDK sysroot. Another option is to explicitly set `CMAKE_PREFIX_PATH`
to the install location in depending projects.
location, you can point `MAGNUM_INCLUDE_INSTALL_PREFIX` there to install the
includes separately. Another option is to explicitly set `CMAKE_PREFIX_PATH`
to the install location in depending projects. Unfortunately, CMake needs extra
help with `CMAKE_FIND_ROOT_PATH` to correctly find Android libraries, otherwise
it falls back to looking in native system locations. Adapt them to your
system, Android ABI and version and NDK location as needed.
Note that `BUILD_STATIC` is implicitly enabled, because manually loading all
depending shared libraries using JNI would be too inconvenient. The engine is
built for OpenGL ES 2.0 by default, switch to 3.0 by disabling `TARGET_GLES2`.
built for OpenGL ES 2.0 by default, switch to 3.0 by disabling `TARGET_GLES2`.
@m_class{m-console-wrap}
@code{.sh}
mkdir build-android-arm64 && cd build-android-arm64
The following guide explains how to build Android projects using minimal
command-line tools, without Android Studio involved.
At the very least you need to have Android SDK and Android NDK installed.
Running console utilities and tests on the device don't need much more, in case
you want to develop actual applications, you need also the SDK and a platform +
SDK platform build tools for version of your choice.
At the very least you need to have Android SDK and Android NDK installed, the guide assumes NDK r19 and newer. Running console utilities and tests on the
device don't need much more, in case you want to develop actual applications,
you need also the SDK and a platform + SDK platform build tools for version of
your choice.
For APK building it's possible to use either an experimental support in CMake
or the official way with Gradle. Gradle is able to download all the
@subsection platforms-android-cmake-too-old CMake is too old
@subsection platforms-android-cmake-too-old CMake or NDK is too old
While the minimal CMake version that's required for building Magnum for Android
is 3.7, you might want to grab at least CMake 3.9.2, as it
[fixes an issue with the Clang toolchain](https://gitlab.kitware.com/cmake/cmake/issues/17253).
is 3.7, NDK r19 and newer need at least CMake 3.16 to work. For older NDKs you
might want to grab at least CMake 3.9.2, as it [fixes an issue with the Clang toolchain](https://gitlab.kitware.com/cmake/cmake/issues/17253).
With NDK r18 and older you'll need to additionally supply
`-DCMAKE_ANDROID_NDK_TOOLCHAIN_VERSION=clang`, on the other hand the
`-DCMAKE_FIND_ROOT_PATH` isn't needed --- CMake is able to figure out the paths
on its own in that case.
@subsection platforms-android-ndk-too-new NDK is too new
@subsection platforms-android-compiler-fails-at-life Compiler suddenly fails at life
If you're suddenly greeted with an overwhelming amount of strange errors coming
from standard library C++ headers including things like
@m_class{m-console-wrap}
@code{.shell-session}
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/cmath:319:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
~~^
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/cmath:320:9: error: no member named 'isgreater' in the global namespace
using ::isgreater;
~~^
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/cmath:321:9: error: no member named 'isgreaterequal' in the global namespace
using ::isgreaterequal;
~~^
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/cmath:322:9: error: no member named 'isless' in the global namespace
using ::isless;
~~^
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/cmath:323:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
~~^
/opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../sysroot/usr/include/c++/v1/cmath:324:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
~~^
@endcode
@m_class{m-noindent}
Last NDK version that's known to be reliably working with CMake is r17, newer
versions suffer from various issues due to changes introduced in NDK internals.
No work has been done yet on Magnum side to counter / work around those issues,
optimistically waiting on CMake devs to figure it out instead. See
[mosra/magnum#310](https://github.com/mosra/magnum/issues/310) for details.
it might be due to `<ndk>/sysroot/usr/include` being present in your
include path. For some reason the NDK has two copies of system includes, one in
`<ndk>/toolchains/llvm/prebuilt/<host>/sysroot/usr` and one here,
and the one in `<ndk>/sysroot` causes the above errors. Find the
offending include dir and point it to the other location to fix the error.
@subsection platforms-android-troubleshooting-windows-nsight CMake complaining about some NVIDIA Nsight Tegra Visual Studio Edition on Windows