使用 com.google.gms: google-services: 4.3.4 出错。

3

我想将Firebase项目与我的应用程序连接。但是,当我添加“classpath” com.google.gms: google-services:4.3.4”时,AS会出现以下错误:

原因:无法找到请求目标的有效认证路径。

我该怎么办?

build.gradle:

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

 buildscript {
repositories {
    google()
    jcenter()
}
dependencies {
    classpath "com.android.tools.build:gradle:4.0.1"
    classpath 'com.google.gms:google-services:4.3.3'

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

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

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

build.gradle(app):

 android {
compileSdkVersion 30
buildToolsVersion "29.0.3"

defaultConfig {
    applicationId "com.vogella.findpeople"
    minSdkVersion 14
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}


 dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.13'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'


implementation 'com.google.firebase:firebase-auth:19.4.0'
implementation 'com.google.firebase:firebase-database:19.5.0'
}

不,它没有帮助。 - Turok
3个回答

0

我遇到了一个类似的问题,涉及到添加这个classpath 'com.google.gms:google-services:4.3.4',但似乎是由于我的网络连接不好,当我有一个强劲的网络连接时,就会出现这个错误,enter image description here

后来我发现这个错误也是由于网络连接不好造成的,在我解决了这个问题之后,又出现了这个错误,enter image description here

这是因为我在app目录下的build.gradle文件中包含了implementation platform('com.google.firebase:firebase-bom:26.0.0')。所以我注释掉它,现在我能够在我的安卓设备上运行Flutter应用程序了。就像这样,enter image description here


0

尝试将apply plugin:行移动到app build.gradle文件中,而不是项目文件中


0

我标记的链接应该适合您。请尝试一下

classpath 'com.google.gms:google-services:4.3.3'

将您的类路径替换为此路径并重新同步。


是的。但现在出现了新错误:无法解析 com.google.firebase:firebase-auth:19.4.0。 - Turok
你在 build.gradle 中使用了 Maven 吗?如果你在这里添加 build.gradle(根目录和应用程序),那么就会很容易解决。如果 SDK 工具与 Google Play 服务版本不兼容,通常会出现此错误。 - Soumik
也请查看这个链接 - Soumik
无法解决依赖项“:app @ debugUnitTest / compileClasspath”的问题:无法解决com.google.firebase:firebase-database:19.4.0。显示详细信息。 - Turok
请在此明确添加两个 build.gradle 代码。一个是 build.gradle(app),另一个是 build.gradle(您的项目名称)。 - Soumik
我添加了两个Gradle,请您现在看一下,好吗? - Turok

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接