Reputation: 81
After adding react-native firebase plugin into my react native app, my app is crashing while launching it.
i'm using RN 0.51, gradle 2.2.3 & 2.14.1
dependencies {
compile project(':react-native-config')
compile project(':react-native-code-push')
compile (project(':react-native-camera')) {
exclude group: "com.android.support"
}
compile "com.android.support:exifinterface:26.1.0"
compile project(':react-native-beacons-manager')
//compile project(':react-native-google-places')
compile project(':react-native-device-info')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
compile 'com.android.support:multidex:1.0.1'
compile project(':react-native-fcm')
compile 'com.google.firebase:firebase-core:10.0.1' //this decides your firebase SDK version
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile project(':react-native-bluetooth-status')
compile project(':react-native-beacons-manager')
compile project(':react-native-vector-icons')
}
These are my plugins i have in my project. in new gradle version all my plugins got obsolete so i downgraded gradle. i tried everything but still my app is crashing and i'm getting the same error. please help me.. thank you
this is my error logs
FATAL EXCEPTION: main Process: com.spazebudenterprise, PID: 8089
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbp;
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:6057)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5628)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5567)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1625)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6339)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.zzbp" on path: DexPathList[[zip file "/data/app/com.spazebudenterprise-1/base.apk"],nativeLibraryDirectories=[/data/app/com.spazebudenterprise-1/lib/arm, /data/app/com.spazebudenterprise-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
Upvotes: 1
Views: 4440
Reputation: 81
Finally i resolved the issue. issue is google services version conflicts between react-native-fcm, react-native-camera, react-native-device-info, react-native-google-places.
i replaced react-native-camera to react-native-camera-kit, react-native-device-info to react-native-device-information and i changed the google play services in google-places plugin to
compile "com.google.android.gms:play-services-base:11.+"
compile "com.google.android.gms:play-services-places:11.+"
compile "com.google.android.gms:play-services-location:11.+"
Upvotes: 0
Reputation: 7517
Make sure you've imported the Google imports into your Gradle plugin and that it's updated ie, version 15.0.0
https://rnfirebase.io/docs/v4.0.x/installation/android
Project build.gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.1'
classpath 'com.google.gms:google-services:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' }
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
app build.gradle file
dependencies {
implementation(project(':react-native-firebase')) {
transitive = false
}
implementation("com.google.android.gms:play-services-base:15.0.0") {
force = true
}
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.facebook.react:react-native:+" // From node_modules
}
/* add the following to the VERY BOTTOM of your app android/app/build.gradle file */
apply plugin: 'com.google.gms.google-services'
gradle-wrapper.properties
found under project_name\android\gradle\wrapper
#Fri Mar 02 12:52:38 IST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
in the terminal
cd android
followed by gradlew clean
or .\gradlew clean
( not sure about the slash, it could ne / or \ try both) then cd ..
and react-native run-android
Upvotes: 1