android - 如何解决找不到com.google.gms :google-services:4. 1.0.?

标签 android gradle build google-api

我遇到了这个错误:

Could not find com.google.gms:google-services:4.1.0.
Required by:
    project :app
Search in build.gradle files

我已经尝试过其他提出相同问题的人在堆栈溢出时显示的其他解决方案:

Could not find com.google.gms:google-services:4.1.0. Searched in the following locations:

Could not find any version that matches com.google.android.gms:play-services-base:[15.0.1,16.0.0)

这是我的应用程序 build.gradle 文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "sg.edu.singaporetech.teamproject"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.facebook.android:facebook-login:4.41.0'
    implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
    implementation 'com.google.firebase:firebase-auth:16.2.0'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    implementation 'com.google.firebase:firebase-storage:16.1.0'
    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.android.support:support-v4:28.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.jjoe64:graphview:4.2.1'
}

apply plugin: 'com.google.gms.google-services'
repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url "https://dl.bintray.com/android/android-tools" }

}

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.1.0'
    }

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

这是我的项目 build.gradle 文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext.kotlin_version = '1.3.21'

    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://dl.bintray.com/android/android-tools" }

    }
    dependencies {
        classpath 'com.google.gms:google-services:4.1.0'
        classpath 'com.android.tools.build:gradle:3.3.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }

}

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "https://dl.bintray.com/android/android-tools" }


    }

}


我希望解决此错误,以便我可以成功构建我的项目。

任何帮助将不胜感激,谢谢。

最佳答案

您添加的插件不止一个。请尝试一下

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "sg.edu.singaporetech.teamproject"
        minSdkVersion 26
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.facebook.android:facebook-login:4.41.0'
    implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
    implementation 'com.google.firebase:firebase-auth:16.2.0'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-database:16.1.0'
    implementation 'com.google.firebase:firebase-storage:16.1.0'
    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.android.support:support-v4:28.0.0'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.jjoe64:graphview:4.2.1'
}

repositories {
    google()
    jcenter()
    mavenCentral()
    maven { url "https://dl.bintray.com/android/android-tools" }

}

buildscript {
    dependencies {
        classpath 'com.google.gms:google-services:4.1.0'
    }

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

更新

尝试使用这个最新版本 'com.google.gms:google-services:4.2.0'

关于android - 如何解决找不到com.google.gms :google-services:4. 1.0.?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55370043/

相关文章:

android - 如何在Service和Activity之间传递复杂的数据?

groovy - 在gradle依赖中指定ivy配置

c++ - 在构建模式下使用#define

android - Gradle 无法解析 com.google.android.gms :play-services-measurement:10. 0.1

gradle - 为什么Gradle在我的插件中找错了位置?

java - Gradle: war 任务有冲突的包含/排除

angular - 如何在 angular2 中禁用 AOT?

如果我尝试修复 gps 坐标,Android 模拟器会重新启动

javascript - 如何在 Phonegap 中使用 angularJs?

android - 在一个应用程序 Activity 中放置两个广告是否违反 admob 规则?