Cannot run program /Users/ganzhixiong/Library/Android/sdk/build-tools/23.0.3/aapt: error=86, Bad CPU type in executable

从 macOS Mojave 10.14.6 更新到 Monterey 12.1 后,Android Studio 编译项目报标题的错误,错误详情如下:

1
2
3
4
5
6
7
8
9
10
11
12
java.io.IOException: Cannot run program "/Users/ganzhixiong/Library/Android/sdk/build-tools/23.0.3/aapt": error=86, Bad CPU type in executable
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at com.android.builder.png.AaptProcess$Builder.start(AaptProcess.java:163)
at com.android.builder.png.QueuedCruncher$1.creation(QueuedCruncher.java:106)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:203)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: error=86, Bad CPU type in executable
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 4 more

原因

因为从 macOS Catalina(10.15.5) 开始已经不支持 32 位的应用了,只能运行64 位的应用。

解决

升级工程的buildToolsVersion

我这里是将工程中的 buildToolsVersion '23.0.3' 修改为 buildToolsVersion '25.0.0' 就没有问题了。
你可以用 /Users/your-name/Library/Android/sdk/build-tools 目录下 build tool 大于或等于 25.0.0 的版本,这样就不用下载了。

Cannot run program /Users/ganzhixiong/Library/Android/sdk/build-tools/23.0.3/aapt: error=86, Bad CPU type in executable

https://ganzhixiong.com/p/7c0d1847/

Author

干志雄

Posted on

2022-03-05

Updated on

2022-03-05

Licensed under

Comments