buildscript {
    ext.safeExtGet = {prop, fallback ->
        rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
    }
    repositories {
        google()
        jcenter()
    }

    dependencies {
        // Matches recent template from React Native (0.60)
        // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16
        classpath("com.android.tools.build:gradle:${safeExtGet('gradlePluginVersion', '3.4.1')}")
    }
}

apply plugin: 'com.android.library'

// Matches values in recent template from React Native (0.59)
// https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L5-L9
def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 28

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

repositories {
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        // Matches recent template from React Native (0.59)
        // https://github.com/facebook/react-native/blob/0.59-stable/template/android/build.gradle#L30
        url "$projectDir/../node_modules/react-native/android"
    }
    mavenCentral()
}

dependencies {
    implementation 'com.yandex.android:mobmetricalib:3.8.0'
    implementation 'com.yandex.android:mobmetricalib-ndk-crashes:1.1.0'
    implementation "com.facebook.react:react-native:${safeExtGet('reactnativeVersion', '+')}"
}
