Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed resolution of com.google.android.gms.maps.GoogleMapOptions #818

Closed
ericnograles opened this issue Nov 22, 2016 · 11 comments
Closed

Comments

@ericnograles
Copy link

Hi guys,

I'm hoping this is something incredibly silly that I'm overlooking. I'm attempting to run a React Native app on an Android Emulator with the following settings:

image

It's basically just a Nexus 6 + Nougat with Google API's installed.

I fire up the application and get a weird exception from com.airbnb.android.react.maps.AirMapManager as follows:

Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/maps/GoogleMapOptions;
...
 Caused by: java.lang.ClassNotFoundException: com.google.android.gms.maps.GoogleMapOptions

Does the exception imply that perhaps Google Play Services is not properly installed on my AVD? I'm guessing yes since running this on my actual Nexus 6P device yields no issues.

The even stranger part is it's already installed on my machine:

image

Is there an extra step I need to take to install Play Services on my emulator?

Thanks for the assist on this!

Eric

@DownMoney
Copy link

DownMoney commented Nov 24, 2016

I had the same issue as you. I managed to get the app running but now I get a message on the map screen that I need to update Google Play services. To fix the compilation error I have added:

compile 'com.google.android.gms:play-services-maps:10.0.0'

to app.gradle. This seems a bit hacky and doesn't solve the map issue but at least you should be able to compile your app.

EDIT:

If you get an error about Dex exceeding max size of 65k add:

compile 'com.android.support:multidex:1.0.0'

to your dependencies and:

multiDexEnabled true

under defaultConfig in your app.gradle

@ogtfaber
Copy link

Had to do the same thing, thanks @DownMoney

@dingbat
Copy link

dingbat commented Dec 6, 2016

I ran into the same thing, but the above fix didn't work for me until I updated the following values in android/app/build.gradle, if it helps anyone (I just followed the pattern in examples/android):

buildToolsVersion "23.0.3"
...
targetSdkVersion 23

@rknell
Copy link

rknell commented Mar 22, 2017

Posting this here because I kept coming back from this page.

I found the final solution, that both compiled and restored maps working here:
googlemaps/android-maps-utils#258

first follow @DownMoney's comments
then add:

    compile "com.google.android.gms:play-services-base:+"
    compile "com.google.android.gms:play-services-maps:+"

instead of compile 'com.google.android.gms:play-services-maps:10.0.0'

@aaronbuchanan
Copy link

aaronbuchanan commented Jun 30, 2017

after doing this I noticed that react-native link will re-link react-native-maps in my android setup... Anyone else?

Edit: I noticed I can trick react-native link into skipping this with a multiline comment:

dependencies {
    /*
    compile project(':react-native-maps')
    */
    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'
    }
    ...

@0mkara
Copy link

0mkara commented Sep 27, 2017

https://medium.com/@suchydan/how-to-solve-google-play-services-version-collision-in-gradle-dependencies-ef086ae5c75f

This explains how to solve this issue. This article made the right solution for me.

@alvelig
Copy link
Contributor

alvelig commented Dec 11, 2017

I recently made a fresh example build.
https://github.com/alvelig/react-native-maps-example.
Try to check it out or build through the README.MD. If it does not help, let me know.

@aswinramakrish
Copy link

aswinramakrish commented Mar 20, 2018

Here is how I debugged this issue -

1. Look at the logs

Here is what I was seeing in mine -

  Fatal Exception: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/maps/GoogleMapOptions;
   at com.airbnb.android.react.maps.AirMapManager.<init>(AirMapManager.java:54)
   at com.airbnb.android.react.maps.MapsPackage.createViewManagers(MapsPackage.java:39)
   at com.facebook.react.ReactInstanceManager.createAllViewManagers(ReactInstanceManager.java:792)
   at com.facebook.react.CoreModulesPackage.createUIManager(CoreModulesPackage.java:175)
   at com.facebook.react.CoreModulesPackage.access$200(CoreModulesPackage.java:55)
   at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:132)
   at com.facebook.react.CoreModulesPackage$7.get(CoreModulesPackage.java:129)
   at com.facebook.react.LazyReactPackage.createNativeModules(LazyReactPackage.java:81)
   at com.facebook.react.NativeModuleRegistryBuilder.processPackage(NativeModuleRegistryBuilder.java:106)
   at com.facebook.react.ReactInstanceManager.processPackage(ReactInstanceManager.java:1202)
   at com.facebook.react.ReactInstanceManager.processPackages(ReactInstanceManager.java:1172)
   at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1107)
   at com.facebook.react.ReactInstanceManager.access$900(ReactInstanceManager.java:113)
   at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:944)

2. Find out the dependencies
Run cd android && ./gradlew :app:dependencies from your root application folder.

You'll see a massive tree (something like the following). Look at the culprits and see which one makes sense corresponding to your logs -

screen shot 2018-03-19 at 5 54 05 pm

3. Fix the dependency

As you can see that com.google.android.gms:play-services-base and com.google.android.gms:play-services-maps had different versions. So I added this to my app's app\build.gradle file dependencies and the app stopped crashing.

compile 'com.google.android.gms:play-services-maps:11.8.0'

@valerybodak
Copy link

valerybodak commented Sep 28, 2018

I solved it by adding these lines:

compile project(':react-native-maps')
compile ("com.google.android.gms:play-services-maps:+") {
      force = true;
}
compile 'com.android.support:multidex:1.0.0'
......

and

defaultConfig {
        ...
        multiDexEnabled true
}

@skout90
Copy link

skout90 commented Jan 2, 2019

@valerybodak Thanks a lot!!

@Ash-faq
Copy link

Ash-faq commented Apr 30, 2019

Posting this here because I kept coming back from this page.

I found the final solution, that both compiled and restored maps working here:
googlemaps/android-maps-utils#258

first follow @DownMoney's comments
then add:

    compile "com.google.android.gms:play-services-base:+"
    compile "com.google.android.gms:play-services-maps:+"

instead of compile 'com.google.android.gms:play-services-maps:10.0.0'

this solution made my day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests