如何解决Android Studio AAPT错误?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (681)

在我所有的Android项目中,都得到了一个AAPT错误。当我寻找使用android.enableAapt 2=false的解决方案时,可能会有帮助,但我经常会遇到这样的错误:

Caused by: java.util.NoSuchElementException
    at com.google.common.collect.AbstractIndexedListIterator.next(AbstractIndexedListIterator.java:80)
    at com.google.common.collect.Iterators.getOnlyElement(Iterators.java:315)
    at com.google.common.collect.Iterables.getOnlyElement(Iterables.java:263)
    at com.android.builder.internal.aapt.v1.AaptV1.makePackageProcessBuilder(AaptV1.java:202)
    at com.android.builder.internal.aapt.AbstractProcessExecutionAapt.makeValidatedPackage(AbstractProcessExecutionAapt.java:67)
    at com.android.builder.internal.aapt.AbstractAapt.link(AbstractAapt.java:34)
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:807)
    ... 56 more

我已经重新安装了AndroidStudio,AndroidSDK并尝试删除我的设置文件

Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details

    Caused by: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$compile$0(QueueableAapt2.java:136)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    ... 1 more
Caused by: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
    at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:443)
    at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:395)
    at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:312)
    at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)
提问于
用户回答回答于

我通过重新安装我的电脑来修复它,问题是因为我的用户名有问题

用户回答回答于

我也犯了同样的错误,下面是我解决这个错误的步骤

-update all files in app.gradle its asking for. 
- update all files in build. gradle its asking for. 
- invalidate cache and restart Android studio.

扫码关注云+社区

领取腾讯云代金券