Android Gradle依赖项冲突和资源重复值

时间:2018-11-13 09:51:14

标签: android firebase gradle android-gradle google-play-services

以下是我的应用程序中的gradle依赖项

ext {
supportLibraryVersion = '27.1.1'
playServicesVersion = '16.0.0'
firebaseVersion = '16.0.4'
}
 dependencies {

implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':pageIndicator')
implementation('io.branch.sdk.android:library:2.+') {
    exclude module: 'answers-shim'
}
implementation 'com.google.zxing:core:3.3.0'
implementation 'com.sothree.slidinguppanel:library:3.1.1'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.jakewharton.picasso:picasso2-okhttp3-downloader:1.1.0'

//Support library
implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
implementation "com.android.support:recyclerview-v7:${supportLibraryVersion}"
implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
implementation "com.android.support:support-v4:${supportLibraryVersion}"
implementation "com.android.support:design:${supportLibraryVersion}"
implementation "com.android.support:customtabs:${supportLibraryVersion}"
implementation "com.android.support:exifinterface:${supportLibraryVersion}"
//Support library

//play services
implementation "com.google.android.gms:play-services-base:${playServicesVersion}"
implementation "com.google.android.gms:play-services-maps:${playServicesVersion}"
implementation "com.google.android.gms:play-services-places:${playServicesVersion}"
implementation "com.google.android.gms:play-services-location:${playServicesVersion}"
implementation "com.google.android.gms:play-services-plus:${playServicesVersion}"
implementation "com.google.android.gms:play-services-auth:16.0.1"
implementation "com.google.android.gms:play-services-analytics:16.0.5"
//play services

implementation 'com.android.volley:volley:1.1.1'
implementation 'com.flurry.android:analytics:7.0.0'
implementation 'com.github.clans:fab:1.6.4'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.0-beta1'

//firebase
implementation "com.google.firebase:firebase-messaging:17.3.4"
implementation "com.google.firebase:firebase-core:16.0.4"
implementation "com.google.firebase:firebase-analytics:16.0.5"
implementation "com.google.firebase:firebase-appindexing:16.0.2"
implementation "com.google.firebase:firebase-ads:17.1.0"
//firebase

implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.squareup.okhttp:okhttp-urlconnection:2.7.5'
implementation 'com.clevertap.android:clevertap-android-sdk:3.1.4'
implementation 'com.ncapdevi:frag-nav:2.4.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'joda-time:joda-time:2.9.9'
implementation 'com.evernote:android-job:1.1.11'
implementation 'com.rengwuxian.materialedittext:library:2.1.4'
implementation 'com.toptoche.searchablespinner:searchablespinnerlibrary:1.3.1'
implementation 'com.bigbangbutton:editcodeview:1.0.5'
implementation 'com.facebook.android:facebook-login:4.30.0'
implementation 'com.github.chrisbanes:PhotoView:2.1.3'
implementation 'com.koushikdutta.async:androidasync:2.+'
implementation 'org.java-websocket:Java-WebSocket:1.3.7'
implementation 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
implementation 'com.google.code.gson:gson:2.8.2'

}

进行构建时出现以下错误消息 请通过更新google-services插件的版本(有关最新版本的信息可从https://bintray.com/android/android-tools/com.google.gms.google-services/获得)或将com.google.android.gms的版本更新为16.0.0来解决版本冲突。

尝试运行以下命令以查看依赖关系树

gradle dependencies --configuration compile

以下是命令的输出

\--- com.google.firebase:firebase-core:16.0.0
 +--- com.google.firebase:firebase-analytics:16.0.0
 |    +--- com.google.android.gms:play-services-basement:15.0.1
 |    |    \--- com.android.support:support-v4:26.1.0
 |    |         +--- com.android.support:support-compat:26.1.0
 |    |         |    +--- com.android.support:support-annotations:26.1.0
 |    |         |    \--- android.arch.lifecycle:runtime:1.0.0
 |    |         |         +--- android.arch.lifecycle:common:1.0.0
 |    |         |         \--- android.arch.core:common:1.0.0
 |    |         +--- com.android.support:support-media-compat:26.1.0
 |    |         |    +--- com.android.support:support-annotations:26.1.0
 |    |         |    \--- com.android.support:support-compat:26.1.0 (*)
 |    |         +--- com.android.support:support-core-utils:26.1.0
 |    |         |    +--- com.android.support:support-annotations:26.1.0
 |    |         |    \--- com.android.support:support-compat:26.1.0 (*)
 |    |         +--- com.android.support:support-core-ui:26.1.0
 |    |         |    +--- com.android.support:support-annotations:26.1.0
 |    |         |    \--- com.android.support:support-compat:26.1.0 (*)
 |    |         \--- com.android.support:support-fragment:26.1.0
 |    |              +--- com.android.support:support-compat:26.1.0 (*)
 |    |              +--- com.android.support:support-core-ui:26.1.0 (*)
 |    |              \--- com.android.support:support-core-utils:26.1.0 (*)
 |    +--- com.google.android.gms:play-services-measurement-base:[15.0.4] -> 15.0.4
 |    +--- com.google.android.gms:play-services-stats:15.0.1
 |    |    \--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1 (*)
 |    +--- com.google.firebase:firebase-analytics-impl:[16.0.0] -> 16.0.0
 |    |    +--- com.google.android.gms:play-services-ads-identifier:15.0.1
 |    |    |    \--- com.google.android.gms:play-services-basement:[15.0.1,16.0.0) -> 15.0.1 (*)
 |    |    +--- com.google.android.gms:play-services-basement:15.0.1 (*)
 |    |    +--- com.google.android.gms:play-services-measurement-base:[15.0.4] -> 15.0.4
 |    |    +--- com.google.android.gms:play-services-stats:15.0.1 (*)
 |    |    +--- com.google.android.gms:play-services-tasks:15.0.1
 |    |    |    \--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1 (*)
 |    |    +--- com.google.firebase:firebase-common:16.0.0
 |    |    |    +--- com.google.android.gms:play-services-basement:15.0.1 (*)
 |    |    |    \--- com.google.android.gms:play-services-tasks:15.0.1 (*)
 |    |    \--- com.google.firebase:firebase-iid:16.0.0
 |    |         +--- com.google.android.gms:play-services-basement:15.0.1 (*)
 |    |         +--- com.google.android.gms:play-services-stats:15.0.1 (*)
 |    |         +--- com.google.android.gms:play-services-tasks:15.0.1 (*)
 |    |         +--- com.google.firebase:firebase-common:16.0.0 (*)
 |    |         \--- com.google.firebase:firebase-iid-interop:16.0.0
 |    |              +--- com.google.android.gms:play-services-base:15.0.1
 |    |              |    +--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1 (*)
 |    |              |    \--- com.google.android.gms:play-services-tasks:[15.0.1] -> 15.0.1 (*)
 |    |              \--- com.google.android.gms:play-services-basement:15.0.1 (*)
 |    \--- com.google.firebase:firebase-common:16.0.0 (*)
 \--- com.google.firebase:firebase-measurement-connector-impl:16.0.0
      +--- com.google.android.gms:play-services-basement:15.0.1 (*)
      +--- com.google.android.gms:play-services-measurement-base:[15.0.4] -> 15.0.4
      +--- com.google.firebase:firebase-analytics:[16.0.0] -> 16.0.0 (*)
      +--- com.google.firebase:firebase-analytics-impl:[16.0.0] -> 16.0.0 (*)
      +--- com.google.firebase:firebase-common:16.0.0 (*)
      \--- com.google.firebase:firebase-measurement-connector:16.0.0
           \--- com.google.android.gms:play-services-basement:15.0.1 (*)

(*)-省略了依赖项(先前列出)

没有弄清楚冲突到底在哪里以及如何解决?

通过如下更新主gradle文件来解决此问题

buildscript {
repositories {
    jcenter()
    google()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:4.0.2'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

 allprojects {
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    maven {
        url "http://dl.bintray.com/piasy/maven"
    }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    google()
}
}

task clean(type: Delete) {
   delete rootProject.buildDir
}

现在出现以下问题

错误:配置'的资源'attr / fontStyle'的重复值。 app \ build \ intermediates \ incremental \ mergeDebugResources \ merged.dir \ values \ values.xml:1421:错误:先前在此处定义的资源。

2 个答案:

答案 0 :(得分:0)

看起来像

com.google.firebase:firebase-analytics

使用com.google.android.gms:play-services-tasks:15.0.1

请更新Firebase。尝试使用

com.google.firebase:firebase-analytics:+

下一步是强制配置:

android{
    configurations.all {
    resolutionStrategy.force "com.google.android.gms:play-services-tasks:${playServicesVersion}"
    }
}

请检查您的构建gradle版本并更新com.android.tools.build:gradle

答案 1 :(得分:0)

更新的主gradle文件解决了此冲突,更新了com.android.tools.build:gradle和 com.google.gms:google-services版本

buildscript {
repositories {
    jcenter()
    google()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.2.1'
    classpath 'com.google.gms:google-services:4.0.2'
    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
 }

allprojects {
repositories {
    jcenter()
    maven { url "https://jitpack.io" }
    maven {
        url "http://dl.bintray.com/piasy/maven"
    }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    google()
}
 }

 task clean(type: Delete) {
delete rootProject.buildDir
 }