每当我尝试构建我的项目时,我都会得到这样的错误:
Android resource compilation failed
Output:
C:\Users\smart\AndroidStudioProjects\ShoppingList\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:497: error: :listItem>.
C:\Users\smart\AndroidStudioProjects\ShoppingList\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:498: error: :listItem>.
C:\Users\smart\AndroidStudioProjects\ShoppingList\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:499: error: :listItem>.
C:\Users\smart\AndroidStudioProjects\ShoppingList\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:503: error: :listItem>.
C:\Users\smart\AndroidStudioProjects\ShoppingList\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:504: error: :listItem>.
Command: C:\Users\smart\.gradle\caches\transforms-1\files-1.1\aapt2-3.3.0-alpha02-4818971-windows.jar\a281fb5dd58b50951126c2252f73d452\aapt2-3.3.0-alpha02-4818971-windows\aapt2.exe compile --legacy \
-o \
C:\Users\smart\AndroidStudioProjects\ShoppingList\app\build\intermediates\res\merged\debug \
C:\Users\smart\AndroidStudioProjects\ShoppingList\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.3.0-alpha02-4818971-windows Daemon #2
有问题的xml行是:
<color name="colorPrimary">#d50000</color>
<color name="colorPrimaryDark">#b71c1c</color>
<color name="colorAccent">#757575</color>
<listItem name="windowActionBar">false</listItem>
<listItem name="windowNoTitle">true</listItem>
我正在使用
classpath 'com.android.tools.build:gradle:3.3.0-alpha02'
我的app gradle文件是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.my.kellen.shoppinglist"
minSdkVersion 14
targetSdkVersion 26
versionCode 2
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.bignerdranch.android:expandablerecyclerview:1.0.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Room components
implementation "android.arch.persistence.room:runtime:1.1.1"
annotationProcessor "android.arch.persistence.room:compiler:1.1.1"
androidTestImplementation "android.arch.persistence.room:testing:1.1.1"
// Lifecycle components
implementation "android.arch.lifecycle:extensions:1.1.1"
annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
}
apply plugin: 'com.google.gms.google-services'
有人能帮我吗?我已经尝试了清理和重建项目,并检查了所有有问题的行。我最近甚至没有修改它们,所以我不知道发生了什么。
编辑-我已经将我的classpath
恢复到3.1.3,并将distributionUrl
恢复到4.5,现在我得到了一个不同的错误消息:
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details.
日志上写着:
error: :listItem>.
Message{kind=ERROR, text=error: :listItem>., sources=`[C:\Users\smart\AndroidStudioProjects\ShoppingList\app\src\main\res\values\styles.xml:17:5-90], original message=, tool name=Optional.of(AAPT)}`
并指向应该有效的两个不同的xml行:
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar"/>
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"/>
发布于 2018-07-06 10:50:41
为什么不改变你的gradle插件版本呢?
首先:通过查看您的gradle文件,' file '->'setting'->'Build,Execuion,Deployment'->' gradle ',找出有多少个本地Gradle可用,然后你会找到这个文件,其中包含一个名为'wrapper\dists‘的文件,打开它,你就会看到它们。
第二:编辑名为' gradle -wrapper.properties‘的文件,并将distributionUrl
的值更改为包含在本地gradle组中的版本。
最后:更改build.gradle
中的classpath
,您可以从中获得帮助的link。
帮助你理解我糟糕的英语,这样我才能帮助你:)
发布于 2018-10-26 18:41:41
我不知道为什么,但这对我的项目有效。比如这个问题,我得到的seam错误就像你的一样。我像这样修复它们:我搜索错误位置
Android resource compilation failed
Output: F:\Works\AndroidProject\lbw\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1703: error: duplicate value for resource 'attr/progress' with config ''.
F:\Works\AndroidProject\lbw\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:1703: error: resource previously defined here.
Command: C:\Users\Administrator\.gradle\caches\transforms-1\files-1.1\aapt2-3.2.1-4818971-windows.jar\802c7c840816e44cd175d342954a2954\aapt2-3.2.1-4818971-windows\aapt2.exe compile --legacy \
-o \
F:\Works\AndroidProject\lbw\app\build\intermediates\res\merged\debug \
F:\Works\AndroidProject\lbw\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
Daemon: AAPT2 aapt2-3.2.1-4818971-windows Daemon #0
然后我搜索文件
F:\Works\AndroidProject\lbw\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml
我在1703 enter image description here行找到了这个位置
我在文件enter image description here中找到了错误的位置
我将名称absProgressBar
search复制到attrs
中,然后得到错误location enter image description here
然后我推荐<!-- <attr name="progress" format="integer" />-->
构建参数,这个错误就会消失。
发布于 2018-11-17 05:01:09
在Android资源编译失败的地方,我得到了类似的东西。
error: <item> inner element must either be a resource reference or empty.
我看到一些帖子建议删除"ids.xml“文件,这解决了这个问题。虽然这可能会修复它,但您可能会造成更大的危害,因为代码可能会引用该id标记。
我通过更新下面的"ids.xml“文件修复了这个问题:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="item_click_support" type="id">id</item>
</resources>
至:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="item_click_support" type="id"/>
</resources>
注意,Item标记现在是一个自动关闭的xml元素。现在,这是在"ids.xml“文件中列出id的正确方法。你也可以参考官方的Android documentation。
干杯!
https://stackoverflow.com/questions/51202130
复制相似问题