【问题标题】:Trying to connect Firebase to app but error which didn't exist 4 monthes ago尝试将 Firebase 连接到应用程序但 4 个月前不存在的错误
【发布时间】:2018-01-13 05:21:11
【问题描述】:

尝试将 Firebase 连接到项目并收到此错误

Error:Execution failed for task ':app:processDebugGoogleServices'.

找不到与包名称“com.google.firebase.udacity.friendlychat”匹配的客户端

我的毕业项目

buildscript {
    repositories {
        jcenter()
        mavenLocal()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:3.1.0'

    }
}

allprojects {
    repositories {
        jcenter()
        mavenLocal()
    }
}

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

Gradle 应用程序

apply plugin: 'com.android.application'

repositories {
    mavenLocal()
    flatDir {
        dirs 'libs'
    }
}

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.google.firebase.udacity.friendlychat"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:appcompat-v7:24.2.0'

    compile 'com.github.bumptech.glide:glide:3.6.1'
}

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

我在 APP 文件夹中添加了 google-services.json。就像 4 个月前一样,一切都很顺利。但现在不行了。

附:我已经从第一页 google -> stack = no results 尝试了一些解决方案。如果你想 -1 请记下,我会提高我使用 stackoverflow 的技能。

谢谢

【问题讨论】:

  • 确保您的应用程序包名称与您的 google-services.json 文件中提及的程序包名称相同。
  • 我已经检查过了
  • 确定您的google-services.json 文件有一个带有正确包名的like this example 块吗?

标签: android firebase firebase-realtime-database firebase-cloud-messaging


【解决方案1】:

再次下载google-services.json。这可能会以某种方式改变。

【讨论】:

    【解决方案2】:

    您正在尝试连接到 Firebase,但您根本没有 Firebase 的 dependencies。如果您想使用我在您的标签中看到的Firebase Realtime DatabaseFirebase Cloud Messaging,请在您的build.gradle 文件中添加以下代码行:

    com.google.firebase:firebase-database:11.8.0
    com.google.firebase:firebase-messaging:11.8.0
    

    如果您需要其他服务,请查看如何Add Firebase to Your Android Project

    别忘了重新下载google-services.json 文件。

    【讨论】:

      猜你喜欢
      • 2020-06-08
      • 1970-01-01
      • 1970-01-01
      • 2020-06-05
      • 2023-02-20
      • 2021-11-10
      • 1970-01-01
      • 2021-08-19
      • 1970-01-01
      相关资源
      最近更新 更多