If you are facing this issue due to arm64 incompatibility, you can try doing exactly what I did.
- First you'll need to update your android/build.gradle file
- Increase the buildToolsVersion to 32 or higher for example
buildscript {
ext {
buildToolsVersion = "33.0.1"
}
}
- If you're using dependencies in your project that explicitly specify build tools version 30, gradle will still attempt to download it and that will cause an error.
To prevent that, you can force all dependencies to use the buildToolsVersion of the main project. It might cause some issues, but if you are lucky, there will be none.
This is how to implement that
buildscript {
subprojects { subproject ->
afterEvaluate{ if((subproject.plugins.hasPlugin("android") || subproject.plugins.hasPlugin("android-library"))) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
}
}
}
}
}
- The binaries in the build and platform tools that sdkmanager will download are for x86_64 so the gradle build will still fail.
To solve this problem, you'll need to either build those tools yourself or download them. After a long search I found these
https://github.com/lzhiyong/android-sdk-tools/releases/download/33.0.3/android-sdk-tools-static-aarch64.zip
All thanks to https://github.com/lzhiyong for building these tools and making them available.
Other releases are here
https://github.com/lzhiyong/android-sdk-tools/releases
After downloading the tools, you should delete the binaries in your android sdk folder and symlink the paths to the downloaded binaries.
The binaries I symlinked in my case are,
Build Tools
aapt
aapt2
aidl
apksigner
zipalign
split-select
dexdump
Platform Tools
fastboot
adb
dmtracedump
e2fsdroid
etc1tool
hprof-conv
make_f2fs
make_f2fs_casefold
mke2fs
sload_f2fs
sqlite3
Most of them won't be used though, but just to be safe.
- Gradle might still download the x86_64 aapt2 version and attempt to use it. To ensure that such doesn't happen,
You can add this line to your android/gradle.properties file
android.aapt2FromMavenOverride=/path-to-downloaded-aapt2-binary
Good luck