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

6

21

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
Impassable answered 14/10, 2019 at 7:43 Comment(0)
C
46

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"
}
Couldst answered 15/10, 2019 at 10:22 Comment(5)
Hi @Dhaval, thanks for your answer. Would you mind editing your post with an explanation that can teach others how your answer solves the problem in question?Allow
worked for me. just add supportLibVersion = "28.0.0" to ext section in build.gradle file.Heathenize
Thanks. To make things clearer, the build.gradle file that is to be edited is the one in android, not in android/app. android/build.gradle has buildscript { ext {} } on top.Valora
@Mahdi Thanks after struggle two days finally get an answer, is this will work fine in ios alsoParamedical
@Mahdi if i am creating new project and add react-native-maps then it's working fine if i am using my old project then i am getting error. i don't know whyParamedical
E
13

Add supportLibVersion = "28.0.0" to buildscript in android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"  // <=== add this line
    }

    ...
}

https://github.com/react-native-community/react-native-maps/issues/3108#issuecomment-552795543

Embryectomy answered 12/11, 2019 at 9:4 Comment(1)
Now that we are forced to change compileSdkVersion to 29, what should we do with the rest of the properties? Keep them as they were? (28.0.0) Increase them? Thanks a lot!Vicinity
W
3

Try installing it directly from github:

npm install --save git+https://[email protected]/react-native-community/react-native-maps.git

Weka answered 12/1, 2020 at 16:56 Comment(0)
C
2

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"/>

Coupe answered 4/11, 2019 at 14:2 Comment(0)
J
2

Add below line in node_modules/react-native-maps/lib/android/build.gradle:

under dependencies

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

Example:
https://github.com/react-native-community/react-native-maps/blob/master/lib/android/build.gradle

Hope it helps.

Just answered 27/11, 2019 at 7:27 Comment(0)
W
0

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.

Woodson answered 17/10, 2019 at 5:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.