Search code examples
androidconan

Invalid NDK - cross compile for Android using Conan manager


I'm trying to install a Conan project for Android on a Windows host.

I created a new profile for this purpose.

Its contents:

[settings]
os=Android
os.api_level=23
os_build=Windows
arch_build=x86_64
arch=armv8
compiler=clang
compiler.libcxx=libc++
compiler.version=9

build_type=Release

[options]
[build_requires]
*: android-ndk/r23, cmake/3.19.0, ninja/1.10.1
[env]

Unfortunately, the result of invoking the command conan install .. --build=missing --profile android-arm64-v8a is an error:

Cross-build from 'Windows:x86_64' to 'Android:armv8'
Installing (downloading, building) binaries...
ERROR: There are invalid packages (packages that cannot exist for this configuration):
android-ndk/r23: Invalid ID: os=Android is not supported by android-ndk (no binaries are available)
android-ndk/r23: Invalid ID: os=Android is not supported by android-ndk (no binaries are available)
android-ndk/r23: Invalid ID: os=Android is not supported by android-ndk (no binaries are available)
android-ndk/r23: Invalid ID: os=Android is not supported by android-ndk (no binaries are available)
android-ndk/r23: Invalid ID: os=Android is not supported by android-ndk (no binaries are available)
android-ndk/r23: Invalid ID: os=Android is not supported by android-ndk (no binaries are available)
android-ndk/r23: Invalid ID: os=Android is not supported by android-ndk (no binaries are available)
android-ndk/r23: Invalid ID: os=Android is not supported by android-ndk (no binaries are available)

What am I doing wrong? How to fix it?


Solution

  • It seems you are still using the legacy cross-build method. But it is probable that most of the recipes in ConanCenter are prepared for the new cross-build method that consist of having 2 profiles:

    • The "build" profile, with settings and options for the current build machine, the machine that is compiling
    • The "host" profile, with settings and options for the machine that will run the code being compiled.

    If you are building for Android from a Windows machine, the "build" profile will be the Windows one, and the "host" one will be the Android one

    Try removing os_build, arch_build from your profile, and use 2 profiles, passing in command line both the --profile:build default (or Windows profile) and --profile:host=android