我想最近使用ConstraintLayout。但这似乎比我想象的要复杂。当我添加依赖项时,编译错误如下:
Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
当我执行gradlew assemble
时,我得到了:
AGPBI: {"kind":"error","text":"error: duplicate value for resource \u0027attr/content\u0027 with config \u0027\u0027.","sources":[{"file":"D:\\Cache\\.gradle\\caches\\transforms-1\\files-1.1\\appcompat-v7-27.1.1.aar\\b4523fa2ae32c684fd710140c71c62d6\\res\\values\\values.xml","position":{"startLine":250,"startColumn":4,"startOffset":27058,"endColumn":68,"endOffset":27122}}],"original":"","tool":"AAPT"}
AGPBI: {"kind":"error","text":"error: resource previously defined here.","sources":[{"file":"D:\\Cache\\.gradle\\caches\\transforms-1\\files-1.1\\appcompat-v7-27.1.1.aar\\b4523fa2ae32c684fd710140c71c62d6\\res\\values\\values.xml","position":{"startLine":250,"startColumn":4,"startOffset":27058,"endColumn":68,"endOffset":27122}}],"original":"","tool":"AAPT"}
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 7s
这是我的build.gradle
文件:
...
repositories {
google()
}
...
dependencies {
def app = rootProject.ext.android
// android support
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.android.support:design:27.1.1"
implementation "com.android.support:palette-v7:27.1.1"
implementation "com.android.support:recyclerview-v7:27.1.1"
implementation "com.android.support:cardview-v7:27.1.1"
implementation "com.android.support:percent:27.1.1"
implementation "com.android.support:support-v4:27.1.1"
implementation "com.android.support:gridlayout-v7:27.1.1"
implementation "com.android.support:support-vector-drawable:27.1.1"
implementation 'com.android.support:multidex:1.0.3'
implementation 'junit:junit:4.12'
implementation "android.arch.lifecycle:extensions:1.1.1"
...
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
我曾尝试清理,重建,失效并重新启动。他们没有工作。我也尝试更新gradle插件。但是我看到了更多的错误。请有人帮我!它困扰了我几天。
PS,您可能需要的信息: