【问题标题】:duplicate value for resource 'attr/tint' with config带有配置的资源“attr/tint”的重复值
【发布时间】:2018-04-02 08:29:21
【问题描述】:

我的android项目构建失败,可以构建成功。

构建:同步

../../../.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.0.aar/079f027781f9663d188d9dd5f4f897cd/res/values/values.xml
错误:资源“attr/tint”与配置“”的重复值。 错误:之前在这里定义的资源。

整个输出:

构建失败 6s 89ms 运行构建 5s 902ms 加载构建 27ms 配置构建 3s 955ms 计算任务图 31ms 运行任务 1s 871ms 空
为以下翻译返回英文:
java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:AAPT2 错误:查看日志了解详细信息

../../../.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.0.aar/079f027781f9663d188d9dd5f4f897cd/res/values/values.xml
错误:资源“attr/tint”与配置“”的重复值。 错误:先前在此处定义的资源。

这是我的依赖。

dependencies {
    implementation(name: 'appboy_release', ext: 'aar')
    testImplementation 'junit:junit:4.12'
    implementation project(':strings')
    implementation project(':osp-core')
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.facebook.android:facebook-android-sdk:4.18.0'
    implementation 'com.android.support:appcompat-v7:27.1.0'
    implementation 'com.android.support:cardview-v7:27.1.0'
    implementation 'com.android.support:design:27.1.0'
    implementation 'com.android.support:gridlayout-v7:27.1.0'
    implementation 'com.android.support:preference-v7:27.1.0'
    implementation 'com.android.support:recyclerview-v7:27.1.0'
    implementation 'com.android.support:support-v4:27.1.0'
    implementation 'com.google.android.gms:play-services-analytics:12.0.1'
    implementation 'com.google.android.gms:play-services-gcm:12.0.1'
    implementation 'com.google.code.gson:gson:2.8.1'
    implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.0.2'
    implementation 'com.sprylab.android.texturevideoview:texturevideoview:1.1.1'
    implementation 'com.makeramen:roundedimageview:2.2.1'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.3.0'
    implementation 'com.squareup.okhttp3:okhttp:3.7.0'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.0.1'
    implementation 'com.squareup.okio:okio:1.12.0'
    implementation 'com.squareup:otto:1.3.3'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.0.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'
    implementation 'com.squareup.retrofit2:retrofit:2.1.0'
    implementation 'com.squareup.sqlbrite:sqlbrite:0.6.3'
    implementation 'de.hdodenhof:circleimageview:2.1.0'
    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'io.reactivex:rxjava:1.2.5'
    implementation 'com.appsflyer:af-android-sdk:4.7.1@aar'
    implementation 'javax.annotation:jsr250-api:1.0'
    implementation 'com.github.chrisbanes.photoview:library:1.2.4'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    implementation('com.twitter.sdk.android:twitter:2.3.1@aar') {
        transitive = true
    }
    implementation project(':loading-widget')
    implementation files('libs/YouTubeAndroidPlayerApi.jar')
}

当我将 Android studio 更新到 3.1 并将 gradle 插件更新到 3.1.0 和 gradle 版本 4.4 (distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip).

在我成功构建之前。

感谢任何帮助。

【问题讨论】:

  • 您在构建之前尝试过清理吗?
  • 使用multidexenable
  • @ReazMurshed 是的,我试过了,但还是失败了。
  • @AbhinavGupta 不幸的是它正在设置中。
  • 删除整个 *build 文件夹(在 *app 文件夹下)并再次清理+重建项目。

标签: android android-studio android-gradle-plugin


【解决方案1】:

对于仍然无法解决此问题的人:

在您的项目中搜索。你会有这样的:

<attr name="tint" format=...... />(主要用于自定义视图)。

您必须重命名该属性名称,然后它应该编译。

【讨论】:

  • 我有同样的问题,我的代码中没有 tint 属性声明。我怀疑其中一个编译库包含它。有没有办法查出是哪一个?
【解决方案2】:

最好的方法是创建一个新的值文件夹名称 values-v21,然后将您的 attr.xml 文件或导致错误的 XML 文件放入该文件夹中,这样它就不会合并或混淆要使用的属性。但是,当然,通过这样做,您是说此属性将仅从 SDK 21 及更高版本开始起作用或使用,这取决于您将选择的版本。

【讨论】:

    猜你喜欢
    • 2018-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多