
def DEFAULT_COMPILE_SDK_VERSION = 28
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
def DEFAULT_MIN_SDK_VERSION = 19
def DEFAULT_TARGET_SDK_VERSION = 28

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

buildscript {
  if (project == rootProject) {
    repositories {            
      google()
      jcenter()
      mavenCentral()            
      maven { url 'https://developer.huawei.com/repo/' }
    }
    dependencies {
      classpath 'com.android.tools.build:gradle:4.1.0'
      classpath 'com.huawei.agconnect:agcp:1.4.1.300'
      classpath 'com.google.gms:google-services:4.3.3'
    }
  }
}

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

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

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 { url 'https://developer.huawei.com/repo/' }
    google()
    jcenter()
    mavenLocal()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
    maven {
        // Android JSC is installed from npm
        url "$rootDir/../node_modules/jsc-android/dist"
    }
}

dependencies {
  String HMSSDKVer ='4.0.0.300'
  String GMSSDKVer ='16.0.1'

  implementation 'com.facebook.react:react-native:+'  // From node_modules
  implementation 'com.google.android.gms:play-services-base:'+ GMSSDKVer
  implementation 'com.huawei.agconnect:agconnect-core:1.0.0.300'
  implementation 'com.huawei.agconnect:agconnect-credential:1.0.0.300'
  implementation 'com.huawei.hms:push:'+ HMSSDKVer // PushKit
  implementation 'com.huawei.hms:hianalytics:' + HMSSDKVer // Analytics Kit
  implementation 'com.huawei.hms:location:+'
  implementation 'com.huawei.hms:maps:+'
}

apply plugin: 'com.huawei.agconnect'