[Solved] ERROR: Unknown host CPU architecture: arm64

ERROR: Unknown host CPU architecture: arm64

When compiling the android ndk project built on Android.mk, I found that the following error occurs on the m1 macbook pro

ERROR: Unknown host CPU architecture: arm64

Need to modify the ndk-build file in the ndk root directory (presumably because the m1 belongs to the arm architecture)

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

Change to

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

Read More: