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

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
........

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 21
  • Comments: 43 (2 by maintainers)

Most upvoted comments

@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",

downgrade react-native version to 0.55.4 then build will success

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

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

here is aworkaround

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

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+” }

@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

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

@salah-ghanim any ETA on publishing to npm?

Anything we can do to help?

@sinodko that’s because your device doesn’t 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’ll see the Play Store logo next to the name on the first step).

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?

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 <uses-library android:name="org.apache.http.legacy" android:required="false"/> 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 )

@MrDatastorage Did you solve you issue?

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

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"
    }
    ...
}

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.

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

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”