react-native-maps: [Android] App crashes on launch java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/maps/GoogleMapOptions
Is this a bug report?
Yes
Have you read the Installation Instructions?
Yes
Environment
react-native: 0.52.2 react: 16.2.0 react-native-maps: 0.20.1
Steps to Reproduce
This didn’t happened before, until today that i tried to compile the project again, I noticed gradle downloaded a ton of stuff, probably updating dependencies. after this, some other npm dependecies had problems, but i sorted that out, then after compiling, the app would crash at startup. inspecting the logcat this error was shown:
FATAL EXCEPTION: Thread-3
05-30 18:21:39.596 30138 30168 E AndroidRuntime: Process: mx.it4pymes.botondepanico, PID: 30138
05-30 18:21:39.596 30138 30168 E AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/maps/GoogleMapOptions;
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.airbnb.android.react.maps.AirMapManager.<init>(AirMapManager.java:54)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.createAllViewManagers(ReactInstanceManager.java:792)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:175)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:55)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:132)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:129)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.LazyReactPackage.createNativeModules(LazyReactPackage.java:81)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:106)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1202)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1172)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1107)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:113)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:944)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at java.lang.Thread.run(Thread.java:761)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.GoogleMapOptions
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at java.lang.VMClassLoader.findLoadedClass(Native Method)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:742)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:362)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: ... 15 more
05-30 18:21:39.596 30138 30168 E AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/internal/safeparcel/zza;
05-30 18:21:39.596 30138 30168 E AndroidRuntime: ... 15 more
05-30 18:21:39.596 30138 30168 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.common.internal.safeparcel.zza" on path: DexPathList[[zip file "/data/app/mx.it4pymes.botondepanico-1/base.apk"],nativeLibraryDirectories=[/data/app/mx.it4pymes.botondepanico-1/lib/arm, /system/fake-libs, /data/app/mx.it4pymes.botondepanico-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
05-30 18:21:39.596 30138 30168 E AndroidRuntime: ... 15 more
05-30 18:21:39.606 1581 1947 W ActivityManager: Force finishing activity mx.it4pymes.botondepanico/.MainActivity
Expected Behavior
The project should just launch as normal
Actual Behavior
The app crashes on startup
I noticed the other dependecies had problems with the com.android.support:support maybe is related to that, I noticed google updated a ton of dependencies recently.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 17
- Comments: 19 (4 by maintainers)
Commits related to this issue
- temp disabled google map for this bug: https://github.com/react-community/react-native-maps/issues/2291 — committed to duytq94/react-native-demo by duytq94 6 years ago
It work by doing this
on the build.gradle of the library, what’s the less hacky way to do this?
My library is on version
0.21.0, I put this onandroid/build.gradle, I used 11.0.4 because all shared libraries seemed to use itchanged the appcompat on
android/app/build.gradleThe error is still this
And my dependency tree looks like this
Help please
OBS: this kind of question fit much better on StackOverflow.
Your problem is: you have version mismatch on resolved version of your support libs, also for play-services libs.
You can detect it on the dependency tree for compile target, where I got those lines from:
How to solve: remove the conflicting dependencies from the library, and re-adding them in your dependencies with the correct version. Check the dependency tree (or build.gradle from libs) to know what to remove from which lib. Example:
see: https://github.com/react-community/react-native-maps/issues/2291#issuecomment-393977077
Sorry, I did’n notice you are not in the latest version of the library.
In this case, the solution would be, in your app gradle file, remove the conflicting dependencies from the library, and re-adding them with the correct version. For example:
Or you can upgrade the library and use the solution given in the comment above.
If someone is still struggling with this, adding
<uses-library android:name="org.apache.http.legacy" android:required="false"/>to the manifest fixed this for me. Check this StackOverflow question+1 Same here with the exact same error. didn’t happen several days ago.
ext { googlePlayServicesVersion = ‘11.0.4’ androidMapsUtilsVersion = ‘0.5’ }
it’s work!!