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

Abhishek Yadav picture Abhishek Yadav · Oct 14, 2019 · Viewed 13k times · Source

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

Answer

Dhaval Kotecha picture Dhaval Kotecha · Oct 15, 2019

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