Reputation: 436
I'm trying to write to my DB with the following "Set up Firebase Realtime Database for Android" example but the app crashes on startup.
It's seems because the dependency:
compile 'com.google.firebase:firebase-database:9.2.1'
The crash log:
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'
How to fix this issue ?
Upvotes: 15
Views: 11757
Reputation: 33
I had same issue when upgrading to Android Studio v3 and upgraded SDKs. Fix consisted in app/Build.gradle to switch to 11.4.2 version:
compile "com.google.android.gms:play-services-base:11.4.2" compile "com.google.firebase:firebase-core:11.4.2"
Into main Build.gradle Move to 3.1.1 version and add maven url
classpath 'com.google.gms:google-services:3.1.1'
maven {
url 'https://maven.google.com'
}
See https://rnfirebase.io/docs/v3.0.*/installation/android#4.-Install-modules
Upvotes: 0
Reputation: 1492
the problem is with the firebase dependencies ....
this is a version compatibility issue
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha7'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.firebaseui:firebase-ui-database:1.0.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
}
mine was a problem with firebase-ui version 1.2.0
then i have changed it with 1.0.1 that matches the other versions of firebase.
for more visit this page....
https://github.com/firebase/FirebaseUI-Android
Upvotes: 0
Reputation: 1311
I was struggling with this too, had both the play-services and firebase on the same version 10.2.0 and still got the exceptions. It was:
compile "com.google.android.gms:play-services-gcm:10.2.0"
compile "com.google.firebase:firebase-messaging:10.2.0"
I eventually just upgraded to 10.2.1
compile "com.google.android.gms:play-services-gcm:10.2.1"
compile "com.google.firebase:firebase-messaging:10.2.1"
and the exceptions were gone!
Upvotes: 2
Reputation: 520
If, like me, you have all your firebase things using the same ver. be sure to check all google related ones too.
For me I had:
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'
compile 'com.google.firebase:firebase-config:10.0.1'
and:
compile 'com.google.android.gms:play-services-ads:10.2.1'
The issue for me wasn't that the firebase didn't match across themselves but that they didn't match the google ver. used for ads.
Changing all my firebase ones to use 10.2.1 solved the issue for me.
So make sure all the firebase ones match the other google ones.
Upvotes: 3
Reputation: 4705
This problem is occur because dependency version mismatch means if use all the library firebase related with unique version like following way.
Wrong way :
compile 'com.google.firebase:firebase-ads:9.6.0'
compile 'com.google.firebase:firebase-database:9.4.0'
compile 'com.google.firebase:firebase-core:9.4.0'
Right way :
compile 'com.google.firebase:firebase-ads:9.6.0'
compile 'com.google.firebase:firebase-database:9.6.0'
compile 'com.google.firebase:firebase-core:9.6.0'
Upvotes: 2
Reputation: 38319
This problem is caused by use of inconsistent Firebase library versions. Update your build dependencies to consistently use version 9.4.0.
compile 'com.google.firebase:firebase-core:9.4.0'
compile 'com.google.firebase:firebase-database:9.4.0'
Upvotes: 38