无法解决:播放服务库

时间:2018-06-23 12:49:12

标签: android android-studio android-gradle build.gradle google-play-services

该错误不允许gradle构建成功。

我的项目级别如下:

buildscript {
    repositories {
        jcenter()

        google()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:4.0.1' 
        classpath 'io.fabric.tools:gradle:1.24.4'

    }
}

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
        google()
    }
}

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

我的应用程序级别gradle文件的依赖性 依赖

{
    implementation 'com.android.support:support-v4:28.0.0-alpha3'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.github.bumptech.glide:glide:4.7.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.7.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation 'com.google.firebase:firebase-messaging:17.0.0'
    implementation 'com.android.support:design:28.0.0-alpha3'
    testCompile 'junit:junit:4.12'
    implementation 'com.startapp:inapp-sdk:3.8.1'
    implementation 'com.android.support:gridlayout-v7:28.0.0-alpha3'
    implementation 'com.android.support:support-v4:28.0.0-alpha3'
}
// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

我的Google存储库版本为58,Android支持存储库为47.0.0,Android SDK构建工具为28.0.0

2 个答案:

答案 0 :(得分:2)

如果您使用的是Windows,只需删除.gradle中的C:\users\"username"文件夹

我从未在LinuxMac中安装过android studio,但必须是:~/.gradle

我的问题通过这种方式解决了。

答案 1 :(得分:0)

照顾好放置google()的顺序

allprojects {
repositories {
    google()
    jcenter()
    maven {
        url "https://maven.google.com"
    }
}