找不到 com.google.gms:google-services:4.2.3

Posted

技术标签:

【中文标题】找不到 com.google.gms:google-services:4.2.3【英文标题】:Could not find com.google.gms:google-services:4.2.3 【发布时间】:2020-11-13 00:22:41 【问题描述】:

FAILURE:构建失败并出现异常。

出了什么问题: 配置根项目“android”时出现问题。 无法解析配置“:classpath”的所有工件。 。

这是我的 android\build.gradle

buildscript 
        ext.kotlin_version = '1.3.50'
        repositories 
            google()
            jcenter()
        
    
        dependencies 
            classpath 'com.android.tools.build:gradle:4.0.0'
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath 'com.google.gms:google-services:4.2.3'
        
    
    
    allprojects 
        repositories 
            google()
            jcenter()
        
    
    rootProject.buildDir = '../build'
    subprojects 
        project.buildDir = "$rootProject.buildDir/$project.name"
    
    subprojects 
        project.evaluationDependsOn(':app')
    
    
    task clean(type: Delete) 
        delete rootProject.buildDir
    

这是我的 android\app\build.gradle

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) 
    localPropertiesFile.withReader('UTF-8')  reader ->
        localProperties.load(reader)
    


def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) 
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")


def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) 
    flutterVersionCode = '1'


def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) 
    flutterVersionName = '1.0'


apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android 
    compileSdkVersion 28

    sourceSets 
        main.java.srcDirs += 'src/main/kotlin'
    

    lintOptions 
        disable 'InvalidPackage'
    

    defaultConfig 
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.shop_app"
        minSdkVersion 16
        targetSdkVersion 28
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

        multiDexEnabled true
    

    buildTypes 
        release 
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        
    


flutter 
    source '../..'


dependencies 
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics:17.2.2'


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

然后我得到了错误

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find com.google.gms:google-services:4.2.3.
     Searched in the following locations:
       - https://dl.google.com/dl/android/maven2/com/google/gms/google-services/4.2.3/google-services-4.2.3.pom
       - https://jcenter.bintray.com/com/google/gms/google-services/4.2.3/google-services-4.2.3.pom
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 5s
Exception: Gradle task assembleDebug failed with exit code 1

我坚持了下来。请帮我解决它。谢谢

【问题讨论】:

【参考方案1】:

版本'com.google.gms:google-services:4.2.3'不存在

您可以使用以下之一:

classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.gms:google-services:4.3.2'
classpath 'com.google.gms:google-services:4.3.1'
classpath 'com.google.gms:google-services:4.3.0'
classpath 'com.google.gms:google-services:4.2.0'

【讨论】:

不错,应该是 4.3.3 谢谢!这是一个很好的解决方案,它对我有用。但是当我运行我的应用程序时出现这样的错误>代码:“sign_in_failed”,详细信息:null,消息:“com.google.android.gms.common.api.ApiException:12500:”。错误是什么? @LornTitya 这是一个不同的问题,它与登录有关。我建议您打开一个包含所有详细信息的新问题。通过这种方式,其他用户可以帮助您。

以上是关于找不到 com.google.gms:google-services:4.2.3的主要内容,如果未能解决你的问题,请参考以下文章

找不到 com.google.gms:google-services:4.0.1 [重复]

错误:找不到 com.google.gms:google-services:1.0。在 android studio 的 build.gradle 中添加谷歌服务插件时

找不到 Glide 的方法 kapt()

风味 - 找不到与包名称匹配的客户端 [重复]

未找到插件 [id: 'com.google.gms.google-services']

未找到 ID 为“com.google.gms.google-services”的插件 打开文件