我正在使用 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/