apply plugin: 'com.android.library'
apply plugin: 'com.huawei.agconnect'

buildscript {
    repositories {
        jcenter()
        mavenCentral()
        google()
        maven { url 'https://developer.huawei.com/repo/' }

    }

    dependencies {
        classpath("com.android.tools.build:gradle:3.6.0")
        classpath("com.huawei.agconnect:agcp:1.9.1.301")
    }
}

android {
    compileSdkVersion 33
    buildToolsVersion "31.0.0"
    defaultConfig {
        minSdkVersion 19
        targetSdkVersion 33
        versionCode 1
        versionName "1.0"
    }
    lintOptions {
        abortOnError false
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

repositories {
    jcenter()
    mavenCentral()
    google()

    maven { url 'https://developer.huawei.com/repo/' }
    maven {
        url "$rootDir/../node_modules/react-native/android"
        // for import com.facebook.react.ReactApplication;
    }

}

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

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.facebook.react:react-native:+'
    implementation 'com.huawei.hms:push:6.12.0.300'

    def supportLibVersion = safeExtGet('supportLibVersion', '27.1.1')
    def supportLibMajorVersion = supportLibVersion.split('\\.')[0] as int
    def appCompatLibName = (supportLibMajorVersion < 20) ? "androidx.appcompat:appcompat" : "com.android.support:appcompat-v7"

    implementation "$appCompatLibName:$supportLibVersion"
}

