react-native-maps: App crashes when using Firebase and react-native-maps

Here is the stacktrace:

FATAL EXCEPTION: main
  Process: com.example, PID: 9308
  java.lang.NoSuchMethodError: No virtual method zztU()Lcom/google/android/gms/dynamic/LifecycleDelegate; in class Lcom/google/android/gms/maps/MapView$zzb; or its super classes (declaration of 'com.google.android.gms.maps.MapView$zzb' appears in /data/app/com.example-2/base.apk)
    at com.google.android.gms.maps.MapView$zzb.zzzW(Unknown Source)
    at com.google.android.gms.maps.MapView$zzb.zza(Unknown Source)
    at com.google.android.gms.dynamic.zza.zza(Unknown Source)
    at com.google.android.gms.dynamic.zza.onCreate(Unknown Source)
    at com.google.android.gms.maps.MapView.onCreate(Unknown Source)
    at com.airbnb.android.react.maps.AirMapView.<init>(AirMapView.java:70)
    at com.airbnb.android.react.maps.AirMapManager.createViewInstance(AirMapManager.java:67)
    at com.airbnb.android.react.maps.AirMapManager.createViewInstance(AirMapManager.java:26)
    at com.facebook.react.uimanager.ViewManager.createView(ViewManager.java:44)
    at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:205)
    at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:148)
    at com.facebook.react.uimanager.UIViewOperationQueue$2.run(UIViewOperationQueue.java:760)
    at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:830)
    at com.facebook.react.uimanager.GuardedChoreographerFrameCallback.doFrame(GuardedChoreographerFrameCallback.java:32)
    at com.facebook.react.uimanager.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:125)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:765)
    at android.view.Choreographer.doCallbacks(Choreographer.java:580)
    at android.view.Choreographer.doFrame(Choreographer.java:549)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:135)
    at android.app.ActivityThread.main(ActivityThread.java:5264)
    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:900)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:695)

P.S. I used manual installation, a.k.a. the com.airbnb.android.react.maps.MapsPackage and not via com.AirMaps.AirPackage. I’ve tried v0.4.2 and v0.5.0

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 9
  • Comments: 36 (10 by maintainers)

Commits related to this issue

Most upvoted comments

I was able to get the map running. This was my final gradle dependencies

configurations.all {
  resolutionStrategy {
    force 'com.google.android.gms:play-services-ads:9.2.0+'
    force "com.google.android.gms:play-services:9.2.0+"
    force "com.google.android.gms:play-services-location:9.2.0+"
    force "com.google.android.gms:play-services-maps:9.2.0+"
    force "com.google.android.gms:play-services-gcm:9.2.0+"
    force "com.google.android.gms:play-services-analytics:9.2.0+"
  }
}

dependencies {
    compile project(':react-native-admob')
    compile project(':react-native-lock')
    compile project(':react-native-vector-icons')
    compile project(':react-native-maps')
    compile project(':react-native-mail')
    compile project(':react-native-linear-gradient')
    compile project(':react-native-image-picker')
    compile project(':react-native-onesignal')
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules

}

Okay, figured it out. This in an incompatibility between Google Play Services 8.4 and Firebase 9.0 (ideally, they should probably be kept on the same version). The trick is to stop including version 8.4 and instead include your desired version 9.0)

My gradle ended up looking like this, though you will most likely need to understand what is going on in the below snippet to adapt it for your purposes.

dependencies {
    compile (project(':react-native-admob')) {
        // exclude version 8.+
        exclude group: 'com.google.android.gms', module: 'play-services-ads'
    }

    compile (project(':react-native-maps')) {
        // exclude version 8.4
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }

    // include whatever firebase packages we want:
    compile 'com.google.firebase:firebase-core:9.0.0'

    // Now re-include an up-to-date version of the packages we excluded above.
    // I believe these basically need to match what we do with firebase, to make things work again
    compile 'com.google.android.gms:play-services-base:9.0.0'
    compile 'com.google.android.gms:play-services-maps:9.0.0'
    compile 'com.google.android.gms:play-services-ads:9.0.0'
}

// Note we must specify an exact version above for firebase, so that the below will work.
// If we specify a '9.+' or '9.0.+' version above, this will error:
apply plugin: 'com.google.gms.google-services'

I had a similar issue (react-native-maps + firebase apparently clashing) and this thread helped me fix it, so I thought I’d share. So basically when I added firebase, my app would crash with “Unfortunately, MyApp has stopped.”. I simple added compile 'com.google.android.gms:play-services-maps:9.2.1' to my android/app/build.gradle and it magically fixed it.

None of this has worked for me, but finally this did the trick.

On your android/app/build.gradle, just place above your dependencies:

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        if (details.requested.group == 'com.google.android.gms' 
            && ( (details.requested.name == 'play-services-base') || (details.requested.name == 'play-services-maps') ) ) {            
            details.useVersion '11.0.2'
        }
    }
}

@redwind Thank you for posting. Changing to 11.+ prevented the crash. When app launched user was prompted to update Google Play services when app launched.

I was using 11.4.2 and app crashed at start due to a firebase gms dependency.

I see current version is 11.7.44.
No sure if 11.+ is going to cause user Google Play update anxiety or not?

/android/app/build.gradle

    compile(project(':react-native-maps')){
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    // Firebase dependencies
    // https://rnfirebase.io/docs/v3.0.*/installation/android
    compile "com.google.android.gms:play-services-base:11.+"
    compile 'com.google.android.gms:play-services-maps:11.+'

    compile "com.google.firebase:firebase-core:11.+"
    compile "com.google.firebase:firebase-analytics:11.+"
    compile "com.google.firebase:firebase-messaging:11.+"    

My crash when using 11.4.2 : Lcom/google/android/gms/common/internal/zzbp

11-08 10:12:36.650  2431  2431 D AndroidRuntime: Shutting down VM
--------- beginning of crash
11-08 10:12:36.651  2431  2431 E AndroidRuntime: FATAL EXCEPTION: main
11-08 10:12:36.651  2431  2431 E AndroidRuntime: Process: com.ditchwitch.fieldscout, PID: 2431
11-08 10:12:36.651  2431  2431 E AndroidRuntime: java.lang.NoSuchMethodError: No static method zzb(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; in class Lcom/google/android/gms/common/internal/zzbp; or its super classes (declaration of 'com.google.android.gms.common.internal.zzbp' appears in /data/app/com.ditchwitch.fieldscout-2/base.apk)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at android.app.ActivityThread.installProvider(ActivityThread.java:5153)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at android.app.ActivityThread.-wrap1(ActivityThread.java)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:102)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:148)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:5417)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
11-08 10:12:36.651  2431  2431 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
11-08 10:12:36.652   569   581 W ActivityManager:   Force finishing activity com.ditchwitch.fieldscout/.MainActivity
11-08 10:12:36.811  1194  1534 I Icing   : Indexing A3DEDC2945BD6907C295655A2388D7A2702EF393 from com.google.android.gms

I got this error when adding firebase-ads:11.6.0. Only solution was to upgrade all firebase components to 11.8.0

@bendellarocco suggestion worked perfectly for me 👍

A proper “fix” to work with Firebase, would be to upgrade react-native-maps’ dependencies to version 9.0.2 (or whatever the latest version of firebase is).

But I only use a tiny bit of maps functionality (basically a static map), and so cannot verify that such a major revision change doesn’t break any of the react-native-maps functionality/apis, and am not comfortable submitting such a pull request.

BTW, these are the things I needed to add to Gradle files: https://firebase.google.com/docs/android/setup

I’ve added core and messaging libraries.