Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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
like image 895
Abhi Avatar asked Oct 14 '19 07:10

Abhi


Video Answer


3 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"
}
like image 129
Dhaval Kotecha Avatar answered Oct 17 '22 10:10

Dhaval Kotecha


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

like image 21
Mahdi Bashirpour Avatar answered Oct 17 '22 09:10

Mahdi Bashirpour


Try installing it directly from github:

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

like image 25
Irfan Khan Avatar answered Oct 17 '22 08:10

Irfan Khan