apply plugin: 'com.android.library'

buildscript {
    // The Android Gradle plugin is only required when opening the android folder stand-alone.
    // This avoids unnecessary downloads and potential conflicts when the library is included as a
    // module dependency in an application project.
    if (project == rootProject) {
        repositories {
            maven { url "https://maven.google.com" }
            mavenCentral()
            google()
        }

        dependencies {
            classpath 'com.android.tools.build:gradle:3.5.4'
        }
    }
}

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

def DEFAULT_COMPILE_SDK_VERSION = 31
def DEFAULT_BUILD_TOOLS_VERSION = "31.0.0"
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 31

android {
  compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
  buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
  defaultConfig {
    minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
    targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
    versionCode 1
    versionName "1.0"
  }
  lintOptions {
    abortOnError false
  }
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

repositories {
  mavenCentral()
}

dependencies {
  implementation fileTree(dir: 'libs', include: ['*.jar'])
  implementation 'com.facebook.react:react-native:+'
  implementation 'org.greenrobot:eventbus:3.+'
  def supportLibVersion = safeExtGet('supportLibVersion', safeExtGet('supportVersion', null))
  def androidXVersion = safeExtGet('androidXVersion', null)
  if (supportLibVersion && androidXVersion == null) {
    implementation "com.android.support:support-annotations:$supportLibVersion"
    implementation "com.android.support:customtabs:$supportLibVersion"
  } else {
    def defaultAndroidXVersion = "1.+"
    if (androidXVersion == null) {
      androidXVersion = defaultAndroidXVersion
    }
    def androidXAnnotation = safeExtGet('androidXAnnotation', androidXVersion)
    def androidXBrowser = safeExtGet('androidXBrowser', androidXVersion)
    implementation "androidx.annotation:annotation:$androidXAnnotation"
    implementation "androidx.browser:browser:$androidXBrowser"
  }
}
  
