113 lines
4.0 KiB
Kotlin
113 lines
4.0 KiB
Kotlin
import java.util.Properties
|
|
|
|
plugins {
|
|
id("com.android.application")
|
|
// The Flutter Gradle Plugin must be applied after the Android plugin.
|
|
id("dev.flutter.flutter-gradle-plugin")
|
|
}
|
|
|
|
val androidSigningPropertiesFile = rootProject.file("key.properties")
|
|
val androidSigningProperties = Properties()
|
|
if (!androidSigningPropertiesFile.isFile) {
|
|
throw GradleException("Missing Android signing properties: $androidSigningPropertiesFile")
|
|
}
|
|
androidSigningPropertiesFile.inputStream().use { androidSigningProperties.load(it) }
|
|
|
|
val umengProperties = Properties()
|
|
val umengPropertiesFile = rootProject.file("../assets/env/.env")
|
|
if (umengPropertiesFile.isFile) {
|
|
umengPropertiesFile.inputStream().use { umengProperties.load(it) }
|
|
}
|
|
|
|
fun umengBuildValue(name: String): String =
|
|
System.getenv(name)?.takeIf { it.isNotBlank() }
|
|
?: umengProperties.getProperty(name)?.trim().orEmpty()
|
|
|
|
fun requireSigningProperty(name: String): String {
|
|
val value = androidSigningProperties.getProperty(name)?.trim()
|
|
if (value.isNullOrBlank()) {
|
|
throw GradleException("Missing Android signing property: $name")
|
|
}
|
|
return value
|
|
}
|
|
|
|
android {
|
|
namespace = "com.jinzhi.butler"
|
|
// permission_handler and the current Android plugin set require API 37.
|
|
compileSdk = 37
|
|
ndkVersion = flutter.ndkVersion
|
|
|
|
signingConfigs {
|
|
create("yanting") {
|
|
keyAlias = requireSigningProperty("keyAlias")
|
|
keyPassword = requireSigningProperty("keyPassword")
|
|
storeFile = file(requireSigningProperty("storeFile"))
|
|
storePassword = requireSigningProperty("storePassword")
|
|
}
|
|
}
|
|
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_17
|
|
targetCompatibility = JavaVersion.VERSION_17
|
|
}
|
|
|
|
defaultConfig {
|
|
// Keep the registered Jinzhi application identity. One-key login and
|
|
// push providers validate the package-and-certificate pair.
|
|
applicationId = "com.jinzhi.butler"
|
|
// You can update the following values to match your application needs.
|
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
|
minSdk = flutter.minSdkVersion
|
|
targetSdk = flutter.targetSdkVersion
|
|
versionCode = flutter.versionCode
|
|
versionName = flutter.versionName
|
|
|
|
ndk {
|
|
abiFilters += "arm64-v8a"
|
|
}
|
|
|
|
val umengChannel = umengBuildValue("UMENG_CHANNEL").ifBlank { "test" }
|
|
manifestPlaceholders.putAll(
|
|
mutableMapOf(
|
|
"UMENG_CHANNEL" to umengChannel,
|
|
"UMENG_APPKEY" to umengBuildValue("UMENG_ANDROID_APP_KEY"),
|
|
"UMENG_MESSAGE_SECRET" to umengBuildValue("UMENG_ANDROID_PUSH_SECRET"),
|
|
"XIAOMI_APP_ID" to umengBuildValue("XIAOMI_APP_ID"),
|
|
"XIAOMI_APP_KEY" to umengBuildValue("XIAOMI_APP_KEY"),
|
|
"OPPO_APP_KEY" to umengBuildValue("OPPO_APP_KEY"),
|
|
"OPPO_APP_SECRET" to umengBuildValue("OPPO_APP_SECRET"),
|
|
"MEIZU_APP_ID" to umengBuildValue("MEIZU_APP_ID"),
|
|
"MEIZU_APP_KEY" to umengBuildValue("MEIZU_APP_KEY"),
|
|
"HUAWEI_APP_ID" to umengBuildValue("HUAWEI_APP_ID"),
|
|
"HONOR_APP_ID" to umengBuildValue("HONOR_APP_ID"),
|
|
"VIVO_APP_KEY" to umengBuildValue("VIVO_APP_KEY"),
|
|
"VIVO_APP_ID" to umengBuildValue("VIVO_APP_ID"),
|
|
)
|
|
)
|
|
}
|
|
|
|
buildTypes {
|
|
debug {
|
|
// U-Verify validates the registered package-and-certificate pair.
|
|
signingConfig = signingConfigs.getByName("yanting")
|
|
}
|
|
release {
|
|
signingConfig = signingConfigs.getByName("yanting")
|
|
proguardFiles(
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
"proguard-rules.pro",
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
kotlin {
|
|
compilerOptions {
|
|
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
|
|
}
|
|
}
|
|
|
|
flutter {
|
|
source = "../.."
|
|
}
|