我综合火力地堡实时数据库我的应用程序里面,我也跟着加说明,但它总是抛出异常火力地堡的getInstance总是抛不虚方法异常
No virtual method
FATAL EXCEPTION: main
Process: appsTest.test, PID: 17680
java.lang.NoSuchMethodError: No virtual method zzcnu()Z in class Lcom/google/firebase/FirebaseApp; or its super classes (declaration of 'com.google.firebase.FirebaseApp' appears in /data/app/appsTest.test-2/base.apk:classes15.dex)
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at appsTest.test.inAppViews.newsFeedScreen.NewsFeedFragment.<init>(NewsFeedFragment.java:31)
at appsTest.test.inAppViews.BaseActivity.onClickOnTab(BaseActivity.java:144)
at appsTest.test.inAppViews.BaseActivity.onTabSelected(BaseActivity.java:258)
at com.ashokvarma.bottomnavigation.BottomNavigationBar.sendListenerCall(BottomNavigationBar.java:578)
at com.ashokvarma.bottomnavigation.BottomNavigationBar.selectTabInternal(BottomNavigationBar.java:558)
at com.ashokvarma.bottomnavigation.BottomNavigationBar.access$000(BottomNavigationBar.java:44)
at com.ashokvarma.bottomnavigation.BottomNavigationBar$1.onClick(BottomNavigationBar.java:502)
at android.view.View.performClick(View.java:6213)
at android.view.View$PerformClick.run(View.java:23645)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
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)
项目gradle这个
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'com.google.gms:google-services:3.0.0'
}
}
应用程序模块gradle:
compile "com.google.firebase:firebase-messaging:+"
compile "com.google.firebase:firebase-core:9.6.1"
compile 'com.google.firebase:firebase-database:9.6.1'
apply plugin: 'com.google.gms.google-services' // this code at the end of gradle file
初始化火力数据库内片段的onCreate方法:
DatabaseReference mRootRefernce = FirebaseDatabase.getInstance().getReference(); // at this line the exception happened
DatabaseReference reference = mRootRefernce.child("feed");
所有的Firebase依赖应该在相同的版本。你为什么使用+作为其中之一?另外,规定的版本9.6.1真的很旧。您的buildscript依赖关系也相当老旧。检查最新的文档。 https://firebase.google.com/docs/android/setup –
@DougStevenson 你是正确的关于+的依赖,我修正了,我也尝试从Android的设置步骤(提供的链接),但它是扔gradle错误: \t 谢谢,但它仍然无法正常工作。我试过了,它给了我这个Gradle错误:错误:执行任务':app:processDebugGoogleServices'失败。 >请修正版本冲突,或者通过更新google-services插件的版本(有关最新版本的信息可在bintray.com/android/android-tools/...上找到)或更新com.google.android.gms的版本到9.0.0。 –