buildscript {
  repositories {
    google()
    mavenCentral()
  }

  dependencies {
    classpath 'com.android.tools.build:gradle:8.7.3'
  }
}

def isNewArchitectureEnabled() {
  return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
}

apply plugin: "com.android.library"


def appProject = rootProject.allprojects.find { it.plugins.hasPlugin("com.android.application") }

if (isNewArchitectureEnabled()) {
  apply plugin: "com.facebook.react"
}

def getExtOrDefault(name) {
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Unimp_" + name]
}

def getExtOrIntegerDefault(name) {
  return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Unimp_" + name]).toInteger()
}

android {
  compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")

  defaultConfig {
    minSdkVersion getExtOrIntegerDefault("minSdkVersion")
    targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
    buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
  }
  buildTypes {
    release {
      minifyEnabled false
    }
  }

  lintOptions {
    disable "GradleCompatible"
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

}

repositories {
  mavenCentral()
  google()
  // flatDir {
  //   dirs "libs"
  // }
}


dependencies {
  // For < 0.71, this will be from the local maven repo
  // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
  //noinspection GradleDynamicVersion
  implementation "com.facebook.react:react-native:+"

  // uni-app
  //导入SDK相关依赖jar、aar
  implementation(group: 'com.uniapp', name: 'android-gif-drawable', version: '5.14', ext: 'aar')
  implementation(group: 'com.uniapp', name: 'base_oaid_sdk', version: '5.14', ext: 'aar')
  implementation(group: 'com.uniapp', name: 'breakpad-build', version: '5.14', ext: 'aar')
  implementation(group: 'com.uniapp', name: 'uniapp-v8', version: '5.14', ext: 'aar')
  implementation(group: 'com.uniapp', name: 'uniMPSDK-V2', version: '5.14', ext: 'aar')
  //必须添加的依赖
  implementation "androidx.recyclerview:recyclerview:1.0.0" // android 自带recyclerview支持
  implementation "androidx.legacy:legacy-support-v4:1.0.0" // androidx support支持
  implementation "androidx.appcompat:appcompat:1.0.0" // androidx appcompat支持
  implementation "com.alibaba:fastjson:1.2.83" // fastjson功能需要
  // 图片加载需要
  implementation "com.facebook.fresco:fresco:2.5.0"
  implementation "com.facebook.fresco:animated-gif:2.5.0"
  implementation "com.facebook.fresco:webpsupport:2.5.0"
  implementation "com.facebook.fresco:animated-webp:2.5.0"
  implementation "com.github.bumptech.glide:glide:4.9.0"

  implementation "com.android.support:multidex:1.0.3"

  implementation "com.squareup.okhttp3:okhttp:3.7.0"
  implementation "com.squareup.okio:okio:1.8.0"
  // 重要：更新版本至1.5.0
  implementation 'androidx.webkit:webkit:1.5.0' // 3.6.15版本之后，用来支持暗黑模式
  // 重要：避免部分设备可能卡死的问题
  annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
}

if (isNewArchitectureEnabled()) {
  react {
    jsRootDir = file("../src/")
    libraryName = "Unimp"
    codegenJavaPackageName = "com.unimp"
  }
}
