unknown property 'supportLibVersion' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler

Viewed 18056

I am getting following error

Could not get unknown property 'supportLibVersion' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHand

I am working on react-native application and react-native-maps dependencies are below in which I am getting error

 dependencies {
      def supportLibMajorVersion = supportLibVersion.split('\\.')[0] as int
      def appCompatLibName =  (supportLibMajorVersion < 20) ? "androidx.appcompat:appcompat" : "com.android.support:appcompat-v7"
      implementation "$appCompatLibName:$supportLibVersion"
      implementation('com.facebook.react:react-native:+') {
        exclude group: 'com.android.support'
      }
      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'
    }

Anyone have idea what is wrong here?

The error in terminal is

FAILURE: Build failed with an exception.

Where:
Build file 'D:\react native\abhishek\Gwala\node_modules\react-native-maps\lib\android\build.gradle' line: 20

What went wrong:
A problem occurred evaluating project ':react-native-maps'.
Could not get unknown property 'supportLibVersion' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

line 20 is

def supportLibMajorVersion = supportLibVersion.split('\\.')[0] as int
6 Answers

Add supportLibVersion = "28.0.0" inside android/build.gradle -> ext

example:

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

Try installing it directly from github:

npm install --save git+https://git@github.com/react-native-community/react-native-maps.git

I solved this issue after these steps:

  1. Add this line to \node_modules\react-native-maps\lib\android\build.gradle -- line: 20

    def supportLibVersion = safeExtGet('supportLibVersion', '28.0.0')

  2. In the AndroidManifest.xml under <application>:

    <uses-library android:name="org.apache.http.legacy" android:required="false"/>

In your file build.gradle inside the android directory

(.../YourApp/android/build.gradle)

find the ext section and add

supportLibVersion = "28.0.0" ext { ... supportLibVersion = "28.0.0" }

that should do the work.

Related