Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error解决方案

升级至Gradle3.0后,若遇到AAPT2导致的编译错误,可通过禁用AAPT2来解决。具体操作为,在gradle.properties文件中添加android.enableAapt2=false,然后重启Gradle后台程序。

升级到Gradle 3.0版本后,编译报错:
*Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

原因 - 摘自官方文档:

构建可能会在启用 AAPT2 时失败。 此外,AAPT2 目前与 Robelectric 不兼容。 如果您的构建因为 AAPT2 资源处理问题失败或者您想要使用 Roboelectric,您可以通过以下方式停用 AAPT2:在您的 gradle.properties 文件中设置 android.enableAapt2=false,并从命令行运行 ./gradlew –stop,重新启动 Gradle 后台程序。

解决方法:

找到gradle.properties文件

加入下面这一句就可以了:

android.enableAapt2=false

StackOverflow的回答:
https://stackoverflow.com/questions/46988102/errorcom-android-tools-aapt2-aapt2exception-aapt2-error-check-logs-for-detail

也可以参考官方文档:官方文档

Execution failed for task ':app:mergeDebugResources'. > 8 exceptions were raised by workers: com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-osx Daemon #0: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-osx Daemon #1: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-osx Daemon #2: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-osx Daemon #3: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-osx Daemon #4: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-osx Daemon #5: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-osx Daemon #6: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. com.android.builder.internal.aapt.v2.Aapt2InternalException: AAPT2 aapt2-3.4.0-5326820-osx Daemon #7: Daemon startup failed This should not happen under normal circumstances, please file an issue if it does. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
06-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值