buildscript {
  repositories {
    google()
    mavenCentral()
  }

  dependencies {
    classpath("com.android.tools.build:gradle:7.2.2")
  }
}

apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION = 29
def DEFAULT_BUILD_TOOLS_VERSION = "29.0.2"
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 29
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION = "18.0.0"

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

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

  lintOptions {
    abortOnError false
  }
}

repositories {
  maven {
    // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
    url(new File(['node', '--print', "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), '../android'))
  }

  maven {
    // Android JSC is installed from npm
    url(new File(['node', '--print', "require.resolve('jsc-android/package.json')"].execute(null, rootDir).text.trim(), '../dist'))
  }
  google()
  mavenCentral()
}
dependencies {
  def googlePlayServicesVersion = safeExtGet('googlePlayServicesVersion', DEFAULT_GOOGLE_PLAY_SERVICES_VERSION)
  googlePlayServicesVersion = safeExtGet('playServicesVersion', googlePlayServicesVersion)
  googlePlayServicesVersion = safeExtGet('playServicesLocationVersion', googlePlayServicesVersion)

  implementation "com.facebook.react:react-native:+"
  implementation 'androidx.appcompat:appcompat:1.0.2'
  implementation "com.google.android.gms:play-services-location:$googlePlayServicesVersion"
}
