React-native-maps: Build Error on React Native 0.59.0 version

Created on 12 Mar 2019  路  43Comments  路  Source: react-native-maps/react-native-maps

Is this a bug report?

YES - The is a Bug

Have you read the Installation Instructions?

YES

Environment

react-native: 0.59.0
react: 16.8.3
react-native-maps: 0.23.0
Target: Android 28

Steps to Reproduce

  1. Create Sample Project using React Native 0.59.0
  2. Install React Native Maps
  3. Run react-native run-android

Expected Behavior

Build Successfully

Actual Behavior

Build Failed

Error Message:

Could not resolve com.android.support:support-compat:28.0.0.
Required by:
      project :react-native-maps > com.facebook.react:react-native:0.59.0 > com.android.support:appcompat-v7:28.0.0
      project :react-native-maps > com.android.support:support-core-utils:28.0.0
      project :react-native-maps > com.android.support:support-fragment:28.0.0
      project :react-native-maps > com.facebook.react:react-native:0.59.0 > com.android.support:appcompat-v7:28.0.0 > com.android.support:support-vector-drawable:28.0.0
      project :react-native-maps > com.android.support:support-core-utils:28.0.0 > com.android.support:loader:28.0.0
      project :react-native-maps > com.android.support:support-core-ui:28.0.0
      project :react-native-maps > com.android.support:support-core-ui:28.0.0 > com.android.support:customview:28.0.0
      project :react-native-maps > com.android.support:support-core-ui:28.0.0 > com.android.support:viewpager:28.0.0
      project :react-native-maps > com.android.support:support-core-ui:28.0.0 > com.android.support:coordinatorlayout:28.0.0
........

Most helpful comment

@kdenz You are right. Next release will fix it!

If you guys prefer to locking to a specific commit you can use the current one:

    "react-native-maps": "https://github.com/react-native-community/react-native-maps.git#c102c36d895cbef8b6a8deefd4c58fb0dc17638e",

All 43 comments

Same issue with me

Any workaround to solve this issue?

same issue here

here is aworkaround

yarn add "react-native-maps@jerolimov/react-native-maps#fix-rn59rc-compile-issues"

@mo-ah-dawood thanks i tried that, the build is successful.

But app crashes when opened view with maps element.

Also tried these changes manually #2702 but still crashes

I've fixed it by simply installing the master branch, as it includes this fix I believe https://github.com/react-native-community/react-native-maps/pull/2702

npm install git://github.com/react-native-community/react-native-maps.git#master --save

@kdenz You are right. Next release will fix it!

If you guys prefer to locking to a specific commit you can use the current one:

    "react-native-maps": "https://github.com/react-native-community/react-native-maps.git#c102c36d895cbef8b6a8deefd4c58fb0dc17638e",

Same issue 馃

@MrDatastorage did you test with the git master version ?

@MrDatastorage did you test with the git master version ?
Yes, I did. React-native-maps error:
A problem occurred configuring project ':app'. Could not resolve all dependencies for configuration ':app:debugCompileClasspath'. More than one variant of project :react-native-maps matches the consumer attributes: - Configuration ':react-native-maps:debugApiElements' variant android-aidl: - Found artifactType 'android-aidl' but wasn't required. - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-api' and found compatible value 'java-api'. - Configuration ':react-native-maps:debugApiElements' variant android-classes: - Found artifactType 'android-classes' but wasn't required. - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-api' and found compatible value 'java-api'. - Configuration ':react-native-maps:debugApiElements' variant android-manifest: - Found artifactType 'android-manifest' but wasn't required. - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-api' and found compatible value 'java-api'. - Configuration ':react-native-maps:debugApiElements' variant android-renderscript: - Found artifactType 'android-renderscript' but wasn't required. - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-api' and found compatible value 'java-api'. - Configuration ':react-native-maps:debugApiElements' variant jar: - Found artifactType 'jar' but wasn't required. - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Found com.android.build.api.attributes.VariantAttr 'debug' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.

Can someone give us an ETA on the next release? Days, weeks, months?

Same as @rangav, adding master did the trick for Android compile but the app keeps crashing on Android when the MapView is ready.
onMapReady gets fired but then the app crashes. I have no error message to understand where it comes from.

On iOS it works fine, no such crashes.

Any idea on to what could cause that?

With master installed, I keep getting blank map with message: AwesomeProject is having trouble with Google Play services. Please try Again.

Edit

everything works fine on iOS

@sinodko that鈥檚 because your device doesn鈥檛 have Google Play Services installed. If you use the android emulator check in the SDK Manager that you downloaded the Google Play Services and then in AVD Manager create a new device using Google Play and not Google APIs (nexus 5 has that option and you鈥檒l see the Play Store logo next to the name on the first step).

@lbtbly hello and thanks for quick response! google maps was working fine on my emulator until yesterday's react-native upgrade :D Do I need to re-install avd anyway?

@lbtbly I've installed Google Play Service from SDK Manager and created new avd for Google Play (instead of Google API) but I'm getting the same message that my project is having trouble with Google Play services :/

Edit

I don't know what happened but when I tried to open MapView Screen third time, the map has loaded :D So it is working! @lbtbly thanks!! :)

Ok I found a solution to the problem of the app crashing on map load:

https://stackoverflow.com/questions/50782806/android-google-maps-java-lang-noclassdeffounderror-failed-resolution-of-lorg-a

@Aleksion
didn't work here what exactly did you do , ive updated the version to 16.1.0 and tried adding the line to android manifest but encountering same issue

@YazeedAsaad I found that solution by running adb logcat. That enables you to see the error that's thrown when it crashes. Would you be able to share that here?

@YazeedAsaad I found that solution by running adb logcat. That enables you to see the error that's thrown when it crashes. Would you be able to share that here?

Just grep all react info: adb logcat | grep react

@MrDatastorage Did you solve you issue?

master works for RN 0.59.1
I just published v0.24-rc1 on github. anyone can use this tag for testing until we get a version out via npm.

I tested with react-native init 0.59.1 on both android and iOS
some config differs from the example project but no changes in config for projects with RN 0.58 or higher

@YazeedAsaad I found that solution by running adb logcat. That enables you to see the error that's thrown when it crashes. Would you be able to share that here?

@Aleksion doesn't crash with me sorry if i made it appear like that when i replied to your message ;
the issue i'm talking about is "the app is having trouble with google play services" message

i also tried 0.59.1 it shows the same message

@YazeedAsaad this issue was solved when using
```
android:name="com.google.android.maps.v2.API_KEY"
android:value="GOOGLE_MAPS_API_KEY"/>

instead of 

 ```
  <meta-data
     android:name="com.google.android.geo.API_KEY"
     android:value="Your Google maps API Key Here"/>

in the android manifest

and make sure in your gradle build file you're using the correct versions of google play services

    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'

@YazeedAsaad this issue was solved when using

      <meta-data
               android:name="com.google.android.maps.v2.API_KEY"
               android:value="GOOGLE_MAPS_API_KEY"/>

instead of

 <meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="Your Google maps API Key Here"/>

in the android manifest

and make sure in your gradle build file you're using the correct versions of google play services

    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'

@salah-ghanim

now it gives me this error
error: package com.airbnb.android.react.maps does not exist

what should i update it to in the mainApplication.java ?
i made sure its linked correctly in settings.gradle and app/build.gradle

@YazeedAsaad the gradle file changes are added on top of your current map project setup

so the full map related parts of the gradle file should look something like this

    implementation(project(':react-native-maps')) {
        exclude group: 'com.google.android.gms', module: 'play-services-base'
        exclude group: 'com.google.android.gms', module: 'play-services-maps'
    }
    implementation 'com.google.android.gms:play-services-base:16.1.0'
    implementation 'com.google.android.gms:play-services-maps:16.1.0'

@salah-ghanim any ETA on publishing to npm?

Anything we can do to help?

Just to inform that when upgrading to 0.59 I don't think I had any crash with the maps (at least on iOS). But from the info on this issue changed from npm to the master of this repo and worked just fine without any issue so far :)

just to let you all know that "app is having trouble with google play services. please try again" was solved by changing com.google.android.gms:play-services-maps from 16.1.0 to 16.0.0 as :

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

downgrade react-native version to 0.55.4 then build will success

Workaround: Open node_modules/react-native-maps/lib/android/build.gradle and copy & place gradle code from #2702.

Seems still issues not resolved for android ,

Tried all the solution from previous comments but no luck showing the map.
1) "react-native-maps@jerolimov/react-native-maps#fix-rn59rc-compile-issues" resolved the compile issues but maps app closed automatically once opened
2)"react-native-maps": "https://github.com/react-native-community/react-native-maps.git#c102c36d895cbef8b6a8deefd4c58fb0dc17638e" still same,
however I've updated same time so app is not closed but it shows blank
The following didn't have any impact for me
ex

  1. updating android:name="com.google.android.maps.v2.API_KEY"
  2. using #2702
  3. downgrading react-native or updating play-services-base & maps

is anyone have fixed and sample source code available in github ? I've used react-native"0.59.0-rc.3"

PS: My google api keys works fine on react projects, ( did enable Google android maps api )

downgrade react-native version to 0.55.4 then build will success

that version of RN will have problems with iOS - Archive as it does not support Xcode 10.

I'm using fine latest version of react native and react native maps from master

After switch to master branch, I can build success on android, but this version cause leak memory in MapView, so I decide to switch back to version 0.23.0 and change build.gradle file of react-native-maps project to :

apply plugin: 'com.android.library'
apply from: 'gradle-maven-push.gradle'

def DEFAULT_COMPILE_SDK_VERSION               = 28
def DEFAULT_BUILD_TOOLS_VERSION               = "28.0.3"
def DEFAULT_TARGET_SDK_VERSION                = 27
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION      = "16.0.1"
def DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION = "16.0.0"
def DEFAULT_ANDROID_MAPS_UTILS_VERSION        = "0.5+"

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

android {
  compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
  buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)

  defaultConfig {
    minSdkVersion 16
    targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
  }

  packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
  }

  lintOptions {
    disable 'InvalidPackage'
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

dependencies {
  def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_VERSION)
  // Variable lookup order : googlePlayServicesMapsVersion > googlePlayServicesVersion > DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION
  def googlePlayServicesMapsVersion = safeExtGet('googlePlayServicesMapsVersion', safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_MAPS_VERSION))
  def androidMapsUtilsVersion = safeExtGet('androidMapsUtilsVersion', DEFAULT_ANDROID_MAPS_UTILS_VERSION)

  compileOnly "com.facebook.react:react-native:+"
  compileOnly('com.facebook.react:react-native:+') {
    exclude group: 'com.android.support'
  }
  implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '28.0.0')}"
  implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
  implementation "com.google.android.gms:play-services-maps:$googlePlayServicesMapsVersion"
  implementation "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"
}

-> android build success and no memory leak.

PS: in project build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
    }
    ...
}

@kduy969 could you please add some more details about the memory leak? In anew issue? 馃

@rborn in IOS, each time I open a screen which contain a <MapView/> , memory go up about 50mb, but when I go back , memory not reduce the same amount ,try this a few times will make app crash. After that, I use Xcode profile tool to monitor leak event, this point out leak memory come from AIRGoogleMap[getActionForTarget] , despite I have no marker on MapView. When I remove <MapView/> from my screen, the issue gone away.

@kduy969 can you open an new issue please.

Thanks @YazeedAsaad
Changing Google play services version from
compile "com.google.android.gms:play-services-base:16.0.1"
to
compile "com.google.android.gms:play-services-maps:16.0.0"
also solved my problem.

Also adding at AndroidManifest.xml <uses-library android:name="org.apache.http.legacy" android:required="false"/>
solved the google map app crashing issue.

Android root build.gradle was also updated with Google play services version googlePlayServicesVersion = "16.0.0" -

ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
googlePlayServicesVersion = "16.0.0"
androidMapsUtilsVersion = "0.5+"
}

Adding <uses-library android:name="org.apache.http.legacy" android:required="false"/> as mentioned by @nazmulhq solved all of my issues!

when I check on the adb logcat

05-15 15:49:53.819 18537 18556 E ReactNativeJS: s is not a function. (In 's()', 's' is 3)
05-15 15:49:53.828 18537 18557 E AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
05-15 15:49:53.828 18537 18557 E AndroidRuntime: Process: com.beaheromobile, PID: 18537
05-15 15:49:53.828 18537 18557 E AndroidRuntime: com.facebook.react.common.JavascriptException: s is not a function. (In 's()', 's' is 3), stack:

Adding <uses-library android:name="org.apache.http.legacy" android:required="false"/> to the AndroidManifest.xml file fixed the issue for me. Thanks @nazmulhq!

RN: 0.59.1

Was this page helpful?
0 / 5 - 0 ratings