我有一个Mac与M1 Max芯片运行Monterey(12.3.1)。我运行Android Studio Chipmunk(2021.2.1补丁1)。因为我更新了操作系统和工作室,我在运行Android SDK的挑战。我的代码在编译过程中抛出以下错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeInternalDebugResources'.
> Multiple task action failures occurred:
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-7.0.3-7396180-osx Daemon #0: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
> A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
> AAPT2 aapt2-7.0.3-7396180-osx Daemon #1: Daemon startup failed
....
Caused by: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-7.0.3-7396180-osx Daemon #7: Daemon startup failed
This should not happen under normal circumstances, please file an issue if it does.
at com.android.builder.internal.aapt.v2.Aapt2Daemon.handleError(Aapt2Daemon.kt:193)
at com.android.builder.internal.aapt.v2.Aapt2Daemon.handleError$default(Aapt2Daemon.kt:190)
at com.android.builder.internal.aapt.v2.Aapt2Daemon.checkStarted(Aapt2Daemon.kt:77)
at com.android.builder.internal.aapt.v2.Aapt2Daemon.compile(Aapt2Daemon.kt:100)
at
com.android.builder.internal.aapt.v2.Aapt2DaemonManager$LeasedAaptDaemon..compile(Aapt2DaemonManager.kt:170)
.....
Caused by: java.io.IOException: Cannot run program "/Users/myuser/.gradle/caches/transforms-3/83c6baf2eeddcf66af012c889d39d1c1/transformed/aapt2-7.0.3-7396180-osx/aapt2": error=86, Bad
CPU type in executable
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1143)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1073)
at com.android.builder.internal.aapt.v2.Aapt2DaemonImpl.startProcess(Aapt2DaemonImpl.kt:86)
at com.android.builder.internal.aapt.v2.Aapt2Daemon.checkStarted(Aapt2Daemon.kt:56)
... 37 more
Caused by: java.io.IOException: error=86, Bad CPU type in executable
at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:314)
at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:244)
at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1110)
... 40 more
由于这是一个AAPT错误,我转到SDK build-tools文件夹30.0.2,并尝试从终端本身运行它,它给出了以下错误(对于AAPT和AAPT 2):
zsh: bad CPU type in executable: ./aapt2
我尝试在32.1.0-rc 1和33.0.0-rc 4中运行相同的工具,结果运行完美。因此,我尝试从/Users位置删除.gradle和.android文件夹,并从Studio工作区删除.gradle。然后从sdk管理器中删除其他构建工具,并重新构建apk。但令我惊讶的是,gradle正在寻找30.0.2构建工具
License for package Android SDK Build-Tools 30.0.2 accepted.
Preparing "Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)".
"Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)" ready.
Installing Android SDK Build-Tools 30.0.2 in /Users/myuser/Library/Android/sdk/build-tools/30.0.2
"Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)" complete.
"Install Android SDK Build-Tools 30.0.2 (revision: 30.0.2)" finished.
所以我假设这个版本的工作室有一个最低要求的构建工具,所以这就是为什么它下载它!但仍然期待它下载一个适当的工作!但仍然给了我同样的AAPT错误!
你知道为什么AAPT/AAPT 2对我不起作用吗?
谢谢提前和快乐编码!!
2条答案
按热度按时间kupeojn61#
在安全模式下启动并重新安装罗塞塔2后终于解决了它!!
cetgtptt2#
我遇到了同样的问题,因为我不想重新启动,我解决了它的“强迫”使用旧的aapt与一个简单的黑客:
请确保将
/Users/username/Library/Android/sdk/build-tools/29.0.2/aapt
替换为有效的aapt路径。