React Native : Task :react-native-maps:compileDebugRenderscript FAILED

After two day's of struggling i find my solution by my self.The real issue is my project using compileSdkVersion = 28 and react-native-maps node_module using different version of compileSdkVersion.

To solve this issue need to update react-native-maps node_module compileSdkVersion version.

project_name>node_modules>react-native-maps>lib>android>build.gradle

 ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 20
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
}

Module compile SDK version and support library version should be same as project compile SDK version and support library version.

this also worked for me.

Modify android/build.gradle as follows

1) Add google() inside repositories

buildscript {
    repositories {
        jcenter()
        // add google() here
        google()

2) Update com.android.tools.build.gradle to 3.1.0

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
      // classpath 'com.android.tools.build:gradle:2.2.3'
      // update from 2.2.3 to 3.1.0 
      classpath 'com.android.tools.build:gradle:3.1.0'

3) Add google() inside repositories after dependencies :

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
      classpath 'com.android.tools.build:gradle:3.1.0'
    }
    allprojects {
      repositories {
        mavenLocal()
        jcenter()
        // add googgle() here
        google()

4) Add android.enableAapt2=false to android/gradle.properties

android.enableAapt2=false // < ---  add here
android.useDeprecatedNdk=true
MYAPP_RELEASE_STORE_FILE=my-release-key.keystore
MYAPP_RELEASE_KEY_ALIAS=my-key-alias

5) Update gradle version in android/gradle/wrapper/gradle-wrapper.properties :

// from version 2.14.1

distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

// change to 4.10.1

distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip

6) Run react-native run-android

Ayesh Nipun

did you able to make it work ?. i found another solution. in my case, this happens because of the version of react-native (0.59.0). so i change my react-native version in my package.json file form 0.59.0 to ^0.58.6. and the react-native-maps version to ^0.23.0. here are the other steps.

1) in app level settings.gradle, include this

include ':react-native-maps'
project(':react-native-maps').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-maps/lib/android')

2) in project level gradle, remove or comment

    ext {
    buildToolsVersion = "28.0.3"
    minSdkVersion = 20
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = "28.0.0"
}

(inside buildscript{})

3) also in project level gradle, change the classpath. build.gradle version to 3.1.1

classpath 'com.android.tools.build:gradle:3.1.1'

also add another url inside maven{} (inside allprojects{})

maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "https://maven.google.com"
            url "$rootDir/../node_modules/react-native/android"
        }

4) now change app level gradle as follows

first, change compileSdkVersion to 28 and add new buildToolVersion

compileSdkVersion 28
buildToolsVersion "27.0.3"

then, change min and target SdkVersion as follows (inside defaultConfig)

defaultConfig {
    applicationId "com.mapviewdemo"
    minSdkVersion 16
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}

5) in your AndroidManifest.xml,

first add this code. this is to give permission to access location on your device. add this before <aplication> tag.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

then you have to add your meta-data before </application> tag.

<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="AIzaSyBTSDBtI7_dfdfBeYkNAtdQ8sT67HiOuO0VU"/>

(add your own API key for android:value)

6) then run npm install and try whether this working or not. if this isn't working, you have to download Android SDK from android studio. in my case, i downloaded Android 7.0 and 6.0

i solved this problem using this npm install — save “[email protected]/react-native-maps#fix-rn59rc-compile-issues”

from: https://github.com/react-native-community/react-native-maps/pull/2702

the problem is with React native 0.59+ that compile with compileSdkVersion 28 and maps use 26

After 2 days I found the problem in my project. I changed the values of compileSdkVersion, supportLibVersion and playServicesVersion in android/build.gradle and android/app/build.gradle files to the same values as in node_modules/react-native-maps/lib/android/build.gradle and node_modules/react-native-maps/build.gradle files, this worked for me.

Values of compileSdkVersion, supportLibVersion and playServicesVersion are same in all the below files.

in android/build.gradle file:

...
ext {
    compileSdkVersion   = 28
    targetSdkVersion    = 27
    buildToolsVersion   = "28.0.3"
    minSdkVersion       = 16
    supportLibVersion   = "28.0.0"
    playServicesVersion = "16.1.0" // or set latest version
    androidMapsUtilsVersion = "0.5+"
}
...

in android/app/build.gradle file:

...
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
    applicationId "com.reactnativeapp2"
    minSdkVersion 19
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    ndk {
        abiFilters "armeabi-v7a", "x86"
    }
}
...
...
}
...
dependencies {
   ...
   ...
   implementation 'com.google.android.gms:play-services-base:16.1.0'
   implementation 'com.google.android.gms:play-services-maps:16.1.0'
}
...

in node_modules/react-native-maps/lib/android/build.gradle file:

...
android {
  compileSdkVersion safeExtGet('compileSdkVersion', 28)

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


dependencies {
  ...
  implementation "com.android.support:appcompat-v7:${safeExtGet('supportLibVersion', '28.0.0')}"
  implementation "com.google.android.gms:play-services-base:${safeExtGet('playServicesVersion', '16.1.0')}"
  implementation "com.google.android.gms:play-services-maps:${safeExtGet('playServicesVersion', '16.1.0')}"
  implementation 'com.google.maps.android:android-maps-utils:0.5'
}
...

in node_modules/react-native-maps/build.gradle file:

...
ext {
    minSdkVersion = 16
    compileSdkVersion = 28
    targetSdkVersion = 28
    supportLibVersion = '28.0.0'
    playServicesVersion = '16.1.0'
  }
...