情况
今天,在没有触及任何项目之后,我的gradle对我大吼大叫,不会编译项目.它无法解决firebase-iid,firebase-common,play-services-analytics-impl,play-services-auth-api-phone和play-services-auth-base.周末过后非常混乱.
所以我检查了不同API的版本,并升级了需要升级的版本,发现Google已经添加了对firebase-core的强制依赖,添加了它,然后升级了我的google-services插件,甚至添加了播放服务 – 基础依赖.我还将firebase-messaging升级到版本17.0.0,将crashlytics升级到版本2.9.3.
The library com.google.android.gms:play-services-measurement-base is being requested by varIoUs other libraries at [[15.0.2,15.0.2], [15.0.4,15.0.4]], but resolves to 15.0.4. disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
Gradle文件
在我尝试修复之后,这是我的Gradle文件(仅显示依赖项部分):
apply plugin: 'com.android.application'
...
dependencies {
implementation project(':library')
implementation project(':otherlibrary')
implementation 'com.android.volley:volley:1.1.0'
implementation('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-analytics:15.0.2'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation('com.google.android.gms:play-services-ads:15.0.1') {
exclude group: 'com.android.support', module: 'customtabs'
}
implementation 'com.google.android.gms:play-services-identity:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-drive:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.daimajia.slider:library:1.1.5@aar'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:exifinterface:27.1.1'
implementation 'com.android.support:support-v13:27.1.1'
// https://mvnrepository.com/artifact/com.darwinsys/hirondelle-date4j
implementation group: 'com.darwinsys', name: 'hirondelle-date4j', version: '1.5.1'
// For RxAndroid and RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
// (see https://github.com/ReactiveX/RxJava/releases for latest 2.x.x version)
implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
// Crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'
// CSV with outputstream writer
implementation 'com.opencsv:opencsv:4.1'
// Gson
implementation 'com.google.code.gson:gson:2.8.5'
debugImplementation 'com.android.support.test:runner:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
androidTestImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
我的项目范围的gradle包含以下行:
...
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
...
}
dependencies {
...
classpath 'com.google.gms:google-services:4.0.1'
}
...
官方解决方案不起作用
我已经尝试根据official firebase documentation修复多个库的版本号,这与this question大致相同.
正如您可以在官方文档链接中看到的那样,截至2018年5月2日,他们提供了一种解决此类问题的方法,但有问题的版本数量并不相同,我已经尝试了给定的修复(与一些降级现在),无济于事.
Official documentation:
If your app has a dependency on com.google.firebase:firebase-core:15.0.0 as well as any of the following libraries:06002
You will need to update the version of the latter dependency to
15.0.2. This addresses the issue where version 3.3.0 of the Google Services Gradle plugin reports: The library
com.google.android.gms:play-services-measurement-base is being
requested by varIoUs other libraries at [[15.0.0,15.0.0],
[15.0.2,15.0.2]], but resolves to 15.0.2…
那么如何才能解决这些版本冲突,以便我的构建能够再次正确编译?
解决方法:
所以在这个问题丢失了一天之后,我发现最新版本的play-services-analytics并不是他们在their website发布的版本.它是16.0.0而不是15.0.2.
Android Studio告诉同事作为警告,但是我对它并不关心.所以这就是改变一切的界限:
implementation 'com.google.android.gms:play-services-analytics:16.0.0'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。