无法解析play-services-auth和firebase-core

时间:2018-07-04 10:47:08

标签: android android-studio android-gradle build.gradle

项目同步失败,出现以下错误。

Failed to resolve: play-services-auth
Open File


Failed to resolve: firebase-core
Open File

尝试将google()替换为maven { url "https://maven.google.com" },但没有好运。这是build.gradle文件的内容。

build.gradle(应用程序)

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

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
plugins {
    id 'com.onesignal.androidsdk.onesignal-gradle-plugin' version '0.7.0'
}

apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
//apply plugin: 'com.google.gms.google-services'

android {
    //other codes
}

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

dependencies {
    //other codes

}

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

build.gradle(项目)

buildscript {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:3.2.0'
    }
}

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

ext {

    minSdkVersion = 16
    targetSdkVersion = 27
    compileSdkVersion = 27

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

如果将apply plugin: 'com.google.gms.google-services'放在apply plugin: 'io.fabric'下方,则会出现以下错误

Could not find com.google.android.gms:play-services-auth-license:11.6.0. Searched in the following locations: https://jcenter.bintray.com/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.pom https://jcenter.bintray.com/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.aar https://jitpack.io/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.pom https://jitpack.io/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.aar https://maven.google.com/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.pom https://maven.google.com/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.aar https://repo.maven.apache.org/maven2/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.pom https://repo.maven.apache.org/maven2/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.aar https://maven.fabric.io/public/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.pom https://maven.fabric.io/public/com/google/android/gms/play-services-auth-license/11.6.0/play-services-auth-license-11.6.0.aar Required by: project :app > com.google.android.gms:play-services-auth:11.4.2

2 个答案:

答案 0 :(得分:1)

您是从firebase项目> app下生成了google-services.json文件,并在底部添加了所有插件

答案 1 :(得分:0)

在您的build.gradle中,引用“ com.facebook.android:account-kit-sdk:4。+”

请使用'com.facebook.android:account-kit-sdk:4.23.0'

而不是'com.facebook.android:account-kit-sdk:4。+'