Skip to content Skip to sidebar Skip to footer

Unknown Host Cpu Architecture: Arm64 , Android Ndk Siliconm1 Apple Macbook Pro

I've got a project that is working fine in windows os but when I switched my laptop and opened an existing project in MacBook Pro M1. I'm unable to run an existing android project

Solution 1:

solved this issue.

Finder -> Go To Folder(/Users/mac/Library/Android/sdk/ndk/21.4.7075529) -> now edit ndk-build open it in text editor and paste below code script and re-run your project.

from

#!/bin/sh
DIR="$(cd "$(dirname "$0")" && pwd)"$DIR/build/ndk-build "$@"

to

#!/bin/sh
DIR="$(cd "$(dirname "$0")" && pwd)"arch -x86_64 /bin/bash $DIR/build/ndk-build "$@"

Reference Link

Solution 2:

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

B

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 "$@"

enter image description here

C

convert your ndk-build into a cmake build

Post a Comment for "Unknown Host Cpu Architecture: Arm64 , Android Ndk Siliconm1 Apple Macbook Pro"