android – Firebase数据库依赖崩溃了应用程序

我正在尝试使用以下“Set up Firebase Realtime Database for Android”示例写入我的数据库,但应用程序在启动时崩溃.

这似乎是因为依赖:

 compile 'com.google.firebase:firebase-database:9.2.1'

崩溃日志:

FATAL EXCEPTION: main
Process: com.example.giat.myapplication, PID: 3874
java.lang.NoSuchMethodError: No static method zzeq(Landroid/content/Context;)Lcom/google/android/gms/internal/zzalp; in class Lcom/google/android/gms/internal/zzalp; or its super classes (declaration of 'com.google.android.gms.internal.zzalp' appears in /data/data/com.example.giat.myapplication/files/instant-run/dex/slice-com.google.firebase-firebase-database-9.2.1_b22e7bdbdba6ace0ee1e94f163c76d1f75b59f7e-classes.dex)
    at com.google.firebase.FirebaseApp.initializeApp(UnkNown Source)
    at com.google.firebase.FirebaseApp.initializeApp(UnkNown Source)
    at com.google.firebase.FirebaseApp.zzek(UnkNown Source)
    at com.google.firebase.provider.FirebaseInitProvider.onCreate(UnkNown Source)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1702)
    at android.content.ContentProvider.attachInfo(ContentProvider.java:1665)
    at com.google.firebase.provider.FirebaseInitProvider.attachInfo(UnkNown Source)
    at android.app.ActivityThread.installProvider(ActivityThread.java:5417)
    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4988)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4923)
    at android.app.ActivityThread.access$1500(ActivityThread.java:144)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1424)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:155)
    at android.app.ActivityThread.main(ActivityThread.java:5696)
    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:1028)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

MY App build.gradle:

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsversion "24.0.1"

defaultConfig {
    applicationId "com.example.giat.myapplication"
    minSdkVersion 15
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile filetree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-database:9.2.1'

}


apply plugin: 'com.google.gms.google-services'

如何解决这个问题?

解决方法:

此问题是由使用不一致的Firebase库版本引起的.更新构建依赖项以始终使用版本9.4.0.

compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...