所以我整天都在浪费,最后决定请你们帮忙。我只想尝试将Firebase与Android Studio项目集成。因此,这是我在应用启动时获得的错误日志。
8-27 04:23:13.285 17651-17651/cr.logics.smashanarchy E/FirebaseApp: Firebase API initialization failure.
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1758)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1733)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:6335)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5927)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5866)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1703)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
Caused by: java.lang.IllegalArgumentException: Given String is empty or null
at com.google.android.gms.common.internal.zzbp.zzgf(Unknown Source)
at com.google.android.gms.internal.zzdkg.<init>(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.<init>(Unknown Source)
at com.google.android.gms.internal.zzdlq.<init>(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.zzb(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
at java.lang.reflect.Method.invoke(Native Method)
at com.google.firebase.FirebaseApp.zza(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.FirebaseApp.initializeApp(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1758)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1733)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:6335)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5927)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5866)
at android.app.ActivityThread.-wrap3(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1703)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6692)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1468)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1358)
我做了一些研究,看起来这条线意味着它没有设法读取google-services.json文件..
Caused by: java.lang.IllegalArgumentException: Given String is empty or null
每当我同步我的gradle文件时,这就是我所得到的。
Configuration on demand is an incubating feature.
please apply google-services plugin at the bottom of the build file.
:Application:preBuild UP-TO-DATE
:Application:preArm7DebugBuild UP-TO-DATE
:Application:checkArm7DebugManifest
:Application:preArm7ReleaseBuild UP-TO-DATE
:Application:prepareComAndroidSupportSupportCompat2520Library
:Application:prepareComAndroidSupportSupportCoreUi2520Library
:Application:prepareComAndroidSupportSupportCoreUtils2520Library
:Application:prepareComAndroidSupportSupportFragment2520Library
:Application:prepareComAndroidSupportSupportMediaCompat2520Library
:Application:prepareComAndroidSupportSupportV42520Library
:Application:prepareComGoogleAndroidGmsPlayServicesAnalytics1120Library
:Application:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl1120Library
:Application:prepareComGoogleAndroidGmsPlayServicesBase1120Library
:Application:prepareComGoogleAndroidGmsPlayServicesBasement1120Library
:Application:prepareComGoogleAndroidGmsPlayServicesTagmanagerV4Impl1120Library
:Application:prepareComGoogleAndroidGmsPlayServicesTasks1120Library
:Application:prepareComGoogleFirebaseFirebaseAnalytics1120Library
:Application:prepareComGoogleFirebaseFirebaseAnalyticsImpl1120Library
:Application:prepareComGoogleFirebaseFirebaseAuth1120Library
:Application:prepareComGoogleFirebaseFirebaseCommon1120Library
:Application:prepareComGoogleFirebaseFirebaseConfig1120Library
:Application:prepareComGoogleFirebaseFirebaseCore1120Library
:Application:prepareComGoogleFirebaseFirebaseDatabase1120Library
:Application:prepareComGoogleFirebaseFirebaseDatabaseConnection1120Library
:Application:prepareComGoogleFirebaseFirebaseIid1120Library
:Application:prepareArm7DebugDependencies
:Application:compileArm7DebugAidl
:Application:compileArm7DebugRenderscript
:Application:generateArm7DebugBuildConfig UP-TO-DATE
:Application:generateArm7DebugResValues UP-TO-DATE
:Application:generateArm7DebugResources
:Application:mergeArm7DebugResources
:Application:processArm7DebugManifest
:Application:processArm7DebugResources
:Application:generateArm7DebugSources
:Application:preArm7DebugAndroidTestBuild UP-TO-DATE
:Application:prepareArm7DebugAndroidTestDependencies
:Application:compileArm7DebugAndroidTestAidl UP-TO-DATE
:Application:processArm7DebugAndroidTestManifest UP-TO-DATE
:Application:compileArm7DebugAndroidTestRenderscript UP-TO-DATE
:Application:generateArm7DebugAndroidTestBuildConfig UP-TO-DATE
:Application:generateArm7DebugAndroidTestResValues UP-TO-DATE
:Application:generateArm7DebugAndroidTestResources UP-TO-DATE
:Application:mergeArm7DebugAndroidTestResources UP-TO-DATE
:Application:processArm7DebugAndroidTestResources UP-TO-DATE
:Application:generateArm7DebugAndroidTestSources UP-TO-DATE
:Application:preArm7DebugUnitTestBuild UP-TO-DATE
:Application:prepareArm7DebugUnitTestDependencies
:Application:mockableAndroidJar UP-TO-DATE
BUILD SUCCESSFUL
Total time: 9.205 secs
所以一开始就说..
please apply google-services plugin at the bottom of the build file.
虽然我已经这样做了。 这就是我的gradle文件的样子..
根目标文件
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
app gradle文件
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.9.3'
}
}
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 23
buildToolsVersion = "25.0.0"
defaultConfig.with {
applicationId = "cr.logics.smashanarchy"
minSdkVersion.apiLevel = 14
targetSdkVersion.apiLevel = 23
}
}
android.ndk {
moduleName = "S3DClient"
cppFlags.addAll(["-I${file("src/main/jni/AIModels")}".toString(),
"-I${file("src/main/jni/S3DX")}".toString(),
"-I${file("src/main/jni")}".toString()])
ldFlags.add("-Wl,--no-whole-archive")
ldFlags.addAll(["-lopenal", "-lssl", "-lcrypto", "-lGLESv2", "-lEGL", "-ldl", "-llog"])
ldFlags.add("-Wl,--no-whole-archive")
ldFlags.addAll(["-lS3DClientNative_Android"])
ldFlags.add("-Wl,--whole-archive")
ldFlags.addAll([])
ldFlags.add("-Wl,--no-whole-archive")
stl = ""
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles.add(file('proguard-rules.txt'))
}
}
android.productFlavors {create ("arm7") {
ndk.abiFilters.add("armeabi-v7a")
ndk.ldFlags.add("-Lsrc/main/jni/prebuilt/engine/armeabi-v7a".toString())
ndk.ldFlags.add("-Lsrc/main/jni/prebuilt/plugins/armeabi-v7a".toString())
ndk.ldFlags.add("-Lsrc/main/jniLibs/armeabi-v7a".toString())
}
// for detailed abiFilter descriptions, refer to "Supported ABIs" @
// https://developer.android.com/ndk/guides/abis.html#sa
// build one including all productFlavors
}
}
dependencies {
compile fileTree(dir: 'src/main/libs', include: ['*.jar'])
compile 'com.google.firebase:firebase-core:11.2.0'
compile 'com.google.firebase:firebase-config:11.2.0'
compile 'com.google.firebase:firebase-auth:11.2.0'
compile 'com.google.firebase:firebase-database:11.2.0'
compile 'com.google.android.gms:play-services-analytics:11.2.0'
}
apply plugin: 'com.google.gms.google-services'
google-services.json文件应该位于app文件夹中。
我有什么不对的吗? 提前谢谢!