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

apply plugin: "com.android.library"

def isAGPVersionGreaterThan(version) {
    try {
        def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
        return agpVersion > version
    } catch (Exception e) {
        return false
    }
}

android {
    // From https://github.com/react-native-community/discussions-and-proposals/issues/671
    // to keep backwards compatibility with RN < 0.71 & AGP < 8
    if (isAGPVersionGreaterThan(7)) {
        namespace "io.split.rnsplit"
    }

    compileSdkVersion safeExtGet("compileSdkVersion", 28)

    defaultConfig {
        minSdkVersion safeExtGet("minSdkVersion", 16)
        targetSdkVersion safeExtGet("targetSdkVersion", 28)
        versionCode 1
        versionName "1.0"
    }
}

dependencies {
    implementation "com.facebook.react:react-native:+"
}
