我在尝试添加Firebase身份验证依赖项时将这行代码添加到我的Android Manifest中:
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
}
apply plugin: 'com.google.gms.google-services'
这就是我在同步Gradle时遇到的错误:
Error:Execution failed for task ':app:processDebugGoogleServices'.
> No matching client found for package name 'ng.org.fafic.fafic'
如何解决此错误?
现在,当我离开我的gradle时:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.android.support:design:24.1.1'
compile 'com.google.firebase:firebase-auth:9.4.0'
}
我的项目将编译没有任何错误。它甚至允许我使用Firebase类进行身份验证。但是当我尝试运行应用程序时,应用程序崩溃了,我留下了这个错误:
Process: ng.org.fafic.fafic, PID: 24478
java.lang.RuntimeException: Unable to start activity ComponentInfo{ng.org.fafic.fafic/ng.org.fafic.fafic.RegisterActivity}: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2808)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6145)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist.
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.getInstance(Unknown Source)
at ng.org.fafic.fafic.RegisterActivity.onCreate(RegisterActivity.java:35)
at android.app.Activity.performCreate(Activity.java:6374)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2752)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2873)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1482)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6145)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
答案 0 :(得分:1)
> No matching client found for package name 'ng.org.fafic.fafic'
如果您的版本中缺少google-services.json
,则会发生此错误
同时根据您的包名检查package_name
中的google-services.json
是否具有正确的值。
{
"project_info": {
},
"client": [
{
"client_info": {
"android_client_info": {
"package_name": "xxxxxxxxxx"
}
...
}
答案 1 :(得分:0)
正如我在您对@Gabriele的回复中看到的那样,请与我联系,如下所示。
首先,检查您是否已经下载了使用Google Play服务/ Firebase的SDK。
检查后,您需要在build.gradle应用程序级别添加Google Play服务lib,而第一个库,我也使用了消息传递:
compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.google.firebase:firebase-messaging:9.0.1'
compile 'com.google.firebase:firebase-core:9.2.1'
在最后一行(所有方括号{}中),你需要添加:
apply plugin: 'com.google.gms.google-services'
现在,在build.gradle项目级别中,您需要添加内部依赖项'括号
classpath 'com.google.gms:google-services:3.0.0'
最重要的部分是你的json文件,下载json文件并导航到你的project / your-app文件夹并将其粘贴到那里,你的app文件夹是包含src / libs / build等文件/文件夹的文件夹。