更新Gradle依赖项后无法解决

时间:2018-06-12 08:16:40

标签: android gradle

更新后,gradle到最新的依赖项包含firebase和play服务:

配置'编译'已经过时,已被“实施”所取代。和' api'。

它将在2018年底删除。有关详细信息,请参阅:http://d.android.com/r/tools/update-dependency-configurations.html

无法解决:play-services-base 打开文件

无法解决:play-services-tasks 打开文件

无法解决:play-services-stats 打开文件

无法解决:play-services-ads-identifier 打开文件

无法解决:play-services-basement 打开文件

build.gradle(app)

implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.android.gms:play-services-analytics:16.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'

我该如何解决?

3 个答案:

答案 0 :(得分:20)

我解决了问题。 这是解决方案

1.add google() before jcenter()
2.exclude group:"com.google.android.gms" in facebook sdk dependencies

我的代码 Gradle:

buildscript {
repositories {
    google()
    jcenter()
}

// something here ...

dependencies {
    classpath 'com.android.tools.build:gradle:3.1.3'
    classpath "io.realm:realm-gradle-plugin:3.1.1"
    classpath 'com.google.gms:google-services:4.0.1'
}
}

allprojects {
repositories {
    google()
    jcenter()
}
}

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

和Myapp / gradle:

repositories {
   maven { url 'https://maven.fabric.io/public' }
   google()
   jcenter()
}

dependencies {
implementation('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') {
    transitive = true
}

implementation ('com.facebook.android:account-kit-sdk:4.28.0'){
    exclude group:"com.google.android.gms"
}
implementation 'com.facebook.android:facebook-android-sdk:4.32.0'

implementation 'com.googlecode.libphonenumber:libphonenumber:8.9.4'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.2'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'

implementation 'com.android.support:multidex:1.0.3'
implementation files('libs/glide-3.8.0.jar')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.squareup.okhttp:okhttp-urlconnection:2.3.0') {
    exclude group: 'com.squareup.okhttp', module: 'okhttp'
}
implementation('com.squareup.okhttp:okhttp:2.3.0') {
    exclude group: 'com.squareup.okio', module: 'okio'
}
implementation 'me.relex:circleindicator:1.2.2@aar'
implementation 'com.android.support:exifinterface:27.1.1'

implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.firebase:firebase-database:16.0.1'

implementation 'com.google.android.gms:play-services-analytics:16.0.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'

}
apply plugin: 'com.google.gms.google-services'

答案 1 :(得分:4)

我有同样的问题,并通过以下方法解决了

在Gradle(项目)中,只需将google()的位置更改为jcenter(),然后进行同步,错误就会消失。

repositories {
    google()
    jcenter()
}

答案 2 :(得分:1)

这是解释。有人有brilliant的想法,仅将pom的{​​{1}}定义上传到JCenter,这意味着如果JCenter是您的首选,它将找到com.google.android.gms:play-services-basement:15.0.1文件,并尝试从同一位置下载POM,但尚未上传到该位置。现在首先使用AAR切换存储库顺序,它将在Google的存储库中正确找到POM和AAR。

从命令行运行google()会告诉您gradle app:build不具备的功能:

Android Studio

您可以在JCenter的网站上看到该工件,其中仅包含POM。

https://bintray.com/bintray/jcenter/com.google.android.gms%3Aplay-services-basement#files/com%2Fgoogle%2Fandroid%2Fgms%2Fplay-services-basement%2F15.0.1

虽然Google存储库具有完整的设置: