react-native-device-info: Crashing on Android

Summary

Version 0.21.5
Affected OS Android
OS Version ?

Current behavior

The app is crashing after linking the library. Here are some screenshots of my code

settings.gradle image

android/build.gradle image

android/app/build.gradle image image

Expected behavior

To work without any errors.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 23

Most upvoted comments

@sircEUNHO If you still facing crash problem then follow these steps. It worked in my case:

  1. Open the project on Android Studio

  2. On app level build.gradle file use same version on all firebase and gms dependencies. dependencies { compile project(‘:react-native-device-info’) compile project(‘:react-native-fcm’) compile fileTree(dir: “libs”, include: [“*.jar”]) compile “com.android.support:appcompat-v7:23.0.1” compile “com.facebook.react:react-native:+” compile ‘com.google.firebase:firebase-core:10.0.1’ compile ‘com.google.firebase:firebase-messaging:10.0.1’ }

  3. Open build.gradle file of react-native-device-info module

  4. Put the same version of dependency on play-services-gcm dependencies { def googlePlayServicesVersion = project.hasProperty(‘googlePlayServicesVersion’) ? project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION

    compile ‘com.facebook.react:react-native:+’ compile “com.google.android.gms:play-services-gcm:10.0.1” }

  5. Open build.gradle of firebase module you installed. In my case it is react-native-fcm

  6. Repeat the same process (use same version for all firebase dependencies) dependencies { def googlePlayServicesVersion = project.hasProperty(‘googlePlayServicesVersion’) ? project.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION

    compile fileTree(include: [‘*.jar’], dir: ‘libs’) compile ‘com.facebook.react:react-native:+’ compile “com.google.firebase:firebase-core:10.0.1” compile “com.google.firebase:firebase-messaging:10.0.1” compile ‘me.leolin:ShortcutBadger:1.1.17@aar’ }

  7. Sync the gradle file and build the project

I was also having the same issue and i simply commented these 3 lines in node_modules/react-native-device-info/android/build.gradle… It works for me!!! Note: I wasn’t using firebase, I was only using react-native-maps & geolocation-location library. Please make sure you have manually linked the library

if(firebaseIidVersion){ // implementation “com.google.firebase:firebase-iid:$firebaseIidVersion” }else{ // def iidVersion = safeExtGet(‘googlePlayServicesIidVersion’, safeExtGet(‘googlePlayServicesVersion’, ‘17.0.0’)) // implementation “com.google.android.gms:play-services-iid:$iidVersion” }

I added this library and got this error on launching the app. It works fine if i remove the react-native-fcm library, but whenever i add both the app crashes. Here is the log of crash :-

06-04 12:26:06.949 5578-5578/com.yudhaapp E/AndroidRuntime: FATAL EXCEPTION: main Process: com.yudhaapp, PID: 5578 java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/zzbq; at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source) at android.app.ActivityThread.installProvider(ActivityThread.java:5153) at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) at android.app.ActivityThread.-wrap1(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.google.android.gms.common.internal.zzbq” on path: DexPathList[[zip file “/data/app/com.yudhaapp-1/base.apk”],nativeLibraryDirectories=[/data/app/com.yudhaapp-1/lib/x86, /data/app/com.yudhaapp-1/base.apk!/lib/x86, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) at java.lang.ClassLoader.loadClass(ClassLoader.java:511) at java.lang.ClassLoader.loadClass(ClassLoader.java:469) at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)  at android.app.ActivityThread.installProvider(ActivityThread.java:5153)  at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)  at android.app.ActivityThread.-wrap1(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.common.internal.zzbq at java.lang.Class.classForName(Native Method) at java.lang.BootClassLoader.findClass(ClassLoader.java:781) at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) at java.lang.ClassLoader.loadClass(ClassLoader.java:504) … 13 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

@sircEUNHO I opened the project on Android Studio and run from it. Android Studio gives logs about crash.