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.
@ -690,8 +690,9 @@ installed files. The following variables are supported:
scripts and other files are installed. CMake on Android by default searches
scripts and other files are installed. CMake on Android by default searches
for binaries in <tt><ndk>/platforms/android-<api>/arch-<arch>/usr</tt>
for binaries in <tt><ndk>/platforms/android-<api>/arch-<arch>/usr</tt>
based on target API and platform, but looks for headers in a central
based on target API and platform, but looks for headers in a central
location at <tt><ndk>/sysroot/usr</tt>. Defaults to ``.``. If a
location at <tt><ndk>/toolchains/llvm/prebuilt/<host>/sysroot/usr</tt>.
relative path is used, it's relative to `CMAKE_INSTALL_PREFIX`.
Defaults to ``.``. If a relative path is used, it's relative to
`CMAKE_INSTALL_PREFIX`.
Various plugin interfaces search for plugins in locations and order documented
Various plugin interfaces search for plugins in locations and order documented
in @ref Corrade::PluginManager::implicitPluginSearchPaths(),
in @ref Corrade::PluginManager::implicitPluginSearchPaths(),
@ -1027,15 +1028,13 @@ to make it available to depending projects.
You will need [Android NDK](https://developer.android.com/ndk/) installed and
You will need [Android NDK](https://developer.android.com/ndk/) installed and
configured and @ref building-corrade-cross-android "Corrade built for Android".
configured and @ref building-corrade-cross-android "Corrade built for Android".
At least CMake 3.7 is required, as it has Android support built-in. The
The guide assumes NDK r19+ with unified Clang toolchain, which in turn requires
supported toolchain is now Clang with libc++, GCC is not supported anymore.
at least CMake 3.16.
Create a build directory and run `cmake` and the build command in it. Set
Create a build directory and run `cmake` and the build command in it. Set
`CMAKE_SYSTEM_NAME` to `Android` to enable the crosscompilation,
`CMAKE_SYSTEM_NAME` to `Android` to enable the crosscompilation,
`CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION` and `CMAKE_ANDROID_STL_TYPE` to use Clang
`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
with libc++, `CMAKE_SYSTEM_VERSION` to minimal API version level you wish to
ABI. Check the [CMake Android cross-compiling documentation](https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-for-android)
use and `CMAKE_ANDROID_ARCH_ABI` to target platform ABI. Check the
The following guide explains how to build Android projects using minimal
The following guide explains how to build Android projects using minimal
command-line tools, without Android Studio involved.
command-line tools, without Android Studio involved.
At the very least you need to have Android SDK and Android NDK installed.
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
Running console utilities and tests on the device don't need much more, in case
device don't need much more, in case you want to develop actual applications,
you want to develop actual applications, you need also the SDK and a platform +
you need also the SDK and a platform + SDK platform build tools for version of
SDK platform build tools for version of your choice.
your choice.
For APK building it's possible to use either an experimental support in CMake
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
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
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
is 3.7, NDK r19 and newer need at least CMake 3.16 to work. For older NDKs you
[fixes an issue with the Clang toolchain](https://gitlab.kitware.com/cmake/cmake/issues/17253).
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
it might be due to `<ndk>/sysroot/usr/include` being present in your
versions suffer from various issues due to changes introduced in NDK internals.
include path. For some reason the NDK has two copies of system includes, one in
No work has been done yet on Magnum side to counter / work around those issues,
`<ndk>/toolchains/llvm/prebuilt/<host>/sysroot/usr` and one here,
optimistically waiting on CMake devs to figure it out instead. See
and the one in `<ndk>/sysroot` causes the above errors. Find the
[mosra/magnum#310](https://github.com/mosra/magnum/issues/310) for details.
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
@subsection platforms-android-troubleshooting-windows-nsight CMake complaining about some NVIDIA Nsight Tegra Visual Studio Edition on Windows