Issue
There are two kinds to build Android with NDK
cmake
externalNativeBuild {
cmake {
path "../sharedCode/CMakeLists.txt"
}
}
This works fine with Apple Silicon M1 👍
ndk-build
externalNativeBuild {
ndkBuild {
path "src/main/jni/Android.mk"
}
}
On a Apple Silicon M1 I run into
Unknown host CPU architecture arm64
The question is to solve this ?
Solution
To solve this on a Apple Silicon M1 I found three options
A
Use NDK 24
android {
ndkVersion "24.0.7956693" // beta 2
...
}
You can install it with
echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install 'ndk;24.0.7956693' --channel=3 1>/dev/null
B
convert your ndk-build
into a cmake
build
C
Change your ndk-build
to use Rosetta x86. Search for your installed ndk with
find ~ -name ndk-build 2>/dev/null
eg
vi ~/Library/Android/sdk/ndk/22.1.7171670/ndk-build
and change
DIR="$(cd "$(dirname "$0")" && pwd)"
$DIR/build/ndk-build "$@
to
DIR="$(cd "$(dirname "$0")" && pwd)"
arch -x86_64 /bin/bash $DIR/build/ndk-build "$@
D
Use a x86 Android Studio version. But this is slow
Answered By - hannes ach
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.