android - Android 资源编译在 3.3.0-alpha02 失败
问题描述
每当我尝试构建我的项目时,都会收到此错误:
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'
我的应用程序 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"/>
解决方案
我不知道为什么,但这对我的项目有用。比如这个问题,我和你的接缝错误一样。我这样修复它们:我搜索错误位置
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 行找到位置 在 此处输入图像描述
我在文件中找到错误位置在 此处输入图像描述
然后我复制名称absProgressBar
搜索attrs
然后我得到错误位置
在此处输入图像描述
比我评论<!-- <attr name="progress" format="integer" />-->
build argen 错误会消失。
推荐阅读
- javascript - Promise 在代码块完成之前解决
- c# - 如何四舍五入到某些数字
- javascript - 如何在 pug 中迭代地图
- c - C 中未调整大小的矩阵:如何将它们作为参数传递给函数,在我的代码中操作并返回它们?
- r - 如何通过 R 访问空气质量 API?
- api - 有什么方法可以在美国获取所有 Twitter 句柄?
- php - 如何在yii2中使弹出窗口水平滚动
- python - python的默认参数值中的None和boolean(True,False)有什么区别?
- c# - 如何在标签统一的 char 上拾取 2 个字符串
- c++ - [OpenCv][C++] 创建一个平滑的、类似喷枪的笔触,类似于 Photoshop?