我正在使用 Google 的 Firebase 数据库。我已经注册到 Firebase 控制台并下载了 JSON 文件,但由于某种原因它给了我这种错误。
错误:任务“:app:processDebugGoogleServices”执行失败。
缺少 api_key/current_key 对象
好吧,我不知道应该把 api 密钥放在哪里。
这是我的 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
in the app/
目录
请参阅文档:https://firebase.google.com/docs/android/setup#add_firebase_to_your_app https://firebase.google.com/docs/android/setup#add_firebase_to_your_app
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)