更新后将无法构建AndroidStudio中的项目

时间:2018-10-31 19:11:19

标签: android-studio

更新AndroidStudio后,我的项目之一无法构建。我还没有找到一个可行的解决方案。我尝试删除其他文件夹和缓存的文件。我也尝试过重新安装android studio,但没有任何帮助。

有人遇到过同样的问题吗?

org.gradle.internal.UncheckedException: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource compilation failed
Output:  /home/erikbylow/Code/privateprojects/workspace-android/TailoredDictFire/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml:2430: error: <item> inner element must either be a resource reference or empty.

Command: /home/erikbylow/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-linux.jar/a3d9a3af204f4221527c5ec7986f58cd/aapt2-3.2.1-4818971-linux/aapt2 compile --legacy \
        -o \
        /home/erikbylow/Code/privateprojects/workspace-android/TailoredDictFire/app/build/intermediates/res/merged/debug \
        /home/erikbylow/Code/privateprojects/workspace-android/TailoredDictFire/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
Daemon:  AAPT2 aapt2-3.2.1-4818971-linux Daemon #2
Output:  /home/erikbylow/Code/privateprojects/workspace-android/TailoredDictFire/app/src/main/res/values/ids.xml:3:5-55: AAPT: error: <item> inner element must either be a resource reference or empty.

Command: /home/erikbylow/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-linux.jar/a3d9a3af204f4221527c5ec7986f58cd/aapt2-3.2.1-4818971-linux/aapt2 compile --legacy \
        -o \
        /home/erikbylow/Code/privateprojects/workspace-android/TailoredDictFire/app/build/intermediates/res/merged/debug \
        /home/erikbylow/Code/privateprojects/workspace-android/TailoredDictFire/app/build/intermediates/incremental/mergeDebugResources/merged.dir/values/values.xml
Daemon:  AAPT2 aapt2-3.2.1-4818971-linux Daemon #2
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:63)
    at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:76)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:124)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:113)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:95)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:73)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at 

1 个答案:

答案 0 :(得分:0)

查看您遇到的错误:

  

TailoredDictFire / app / build / intermediates / incremental / mergeDebugResources / merged.dir / values / values.xml:2430:错误:内部元素必须是资源引用或为空。

AAPT2告诉您,合并值文件中的第2430行上有一个资源,该资源的值不正确-它应该是资源引用或为空。如果我没记错的话,这是在定义ID资源并将例如字符串或整数作为其值的时候。它要么根本没有值,要么应该引用其他ID(“ @ id / other_id”)。

查看该行中的资源。您是否认识到它来自您的应用程序?如果确实定义了它,请确保将其修复在值文件(app/src/main/res/values)中:

<id name="my_id">my value</id> -> <id name="my_id" />

如果它来自外部库,则可以尝试通过在资源中定义具有匹配类型和名称的资源来覆盖它。