android - Firebase - 缺少 Api key

标签 android firebase

我正在使用 Google 的 Firebase 数据库。我已注册到 Firebase 控制台并下载了 JSON 文件,但由于某种原因它给了我这种错误。

Error:Execution failed for task ':app:processDebugGoogleServices'. Missing api_key/current_key object

好吧,我不知道应该将 api key 放在哪里。

这是我的 gradle(模块应用程序)

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

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

defaultConfig {
    applicationId "com.udacity.firebase.shoppinglistplusplus"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        it.buildConfigField 'String','UNIQUE_FIREBASE_ROOT_URL', UniqueFirebaseRootUrl
    }
    debug {
    }
}

/* This for anyone following along with the repo. Since you will have a different
 * root URL, this code loads up a value from your gradle.properties file.
 */

buildTypes.each {
    it.buildConfigField 'String', 'UNIQUE_FIREBASE_ROOT_URL', UniqueFirebaseRootUrl
}

packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE-FIREBASE.txt'
    exclude 'META-INF/NOTICE'
}

 }

 dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:design:23.0.1'
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'

/* Firebase SDK */
compile 'com.firebase:firebase-client-android:2.4.0'

/* Firebase UI */
compile 'com.firebaseui:firebase-ui:0.2.2'

/* For Google Play Services */
compile 'com.google.android.gms:play-services-safetynet:9.0.0'
compile 'com.google.android.gms:play-services-auth:9.0.0'

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

这是 gradle(项目)

   // Top-level build file where you can add configuration options common to     
       all sub-projects/modules.

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

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

  allprojects {
     repositories {
      jcenter()
      }
  }

如果缺少什么,请告诉我

最佳答案

您应该将 google-services.json 放在 app/ 目录中

参见文档:https://firebase.google.com/docs/android/setup#add_firebase_to_your_app

关于android - Firebase - 缺少 Api key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40270202/

相关文章:

android - 内部测试轨道 - 无法下载最新版本

android - android中如何访问多个数据库表的数据?

android - 我如何获取插入到sqlite数据库中的最后一个值

javascript - 如何在 Firebase 中获取元素/列表的大小而不获取全部?

java - 如何通过 toObject 方法附​​加附加数据?

android - 重置特定偏好 Android

java - 如何对 Telegram api 进行 RPC 调用?

xcode - 使用 Firebase Unity SDK 时出现 Firebase Xcode 链接器命令错误

IOS - 限制用户最多选择 8 个图像并使用 For 循环将多个图像上传到 Firebase

android - 基于 Firebase 控制台的通知中消息文本的字符限制是多少?