【问题标题】:Error using com.google.gms: google-services: 4.3.4使用 com.google.gms 时出错:google-services: 4.3.4
【发布时间】:2020-10-03 15:14:12
【问题描述】:

我正在尝试将 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'
}

【问题讨论】:

标签: android firebase


【解决方案1】:

我标记的链接应该对你有用。试试这个

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

用这个替换你的类路径并重新同步。

【讨论】:

  • 是的。 BUt 现在出现新错误:无法解析 com.google.firebase:firebase-auth:19.4.0。
  • 你在 build.gradle 中使用过 maven 吗?如果在此处添加 build.gradle(root 和 app)会很容易。如果 SDK 工具不是最新的 google play 服务版本,通常会出现此错误
  • 也看看this
  • 无法解析 ':app@debugUnitTest/compileClasspath' 的依赖关系:无法解析 com.google.firebase:firebase-database:19.4.0。显示详情
  • 请在此处明确添加两个 build.gradle 代码。一个是 build.gradle (app) 和 build.gradle (你的项目名称)。
【解决方案2】:

尝试将您的 apply plugin: 行移动到应用程序 build.gradle 文件而不是项目文件中

【讨论】:

    【解决方案3】:

    我在添加此classpath 'com.google.gms:google-services:4.3.4' 时遇到了类似的问题,但我的互联网连接似乎很糟糕,当我有强大的互联网连接时,出现了这个错误,

    我还想到这个错误也是由于互联网连接不佳,在我修复之后发生了这个错误,

    这是因为我在app 目录中的build.gradle 文件中包含了这个implementation platform('com.google.firebase:firebase-bom:26.0.0')。所以我commented it out 现在我可以在我的安卓设备上运行颤振应用了。像这样,

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-19
      • 1970-01-01
      • 2016-03-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多