Files
QingTing-Player/android/app/build.gradle.kts
T
lxh2875931338 ff41769c56 build(android): 接入正式签名配置 + 版本号改为 1.1.0-dev.1 (2)
- app/build.gradle.kts 读取 android/key.properties(不存在时回退 debug keystore)
- .gitignore 忽略 key.properties / keystore / *.jks
- pubspec: version 1.1.0-dev.1+2

注意:key.properties 与 keystore 文件由开发者本地生成,不入库。
生成后 flutter build apk --release 即为正式签名包。
2026-10-24 00:11:53 +08:00

102 lines
3.6 KiB
Kotlin
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
plugins {
id("com.android.application")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
// 正式签名:android/key.properties(不入库)
// 文件缺失时自动回退到 debug keystore,保证 clone 下来也能直接构建
import java.io.FileInputStream
import java.util.Properties
val keystorePropertiesFile = rootProject.file("key.properties")
val keystoreProperties = Properties()
val hasReleaseKeystore = keystorePropertiesFile.exists()
if (hasReleaseKeystore) {
FileInputStream(keystorePropertiesFile).use { keystoreProperties.load(it) }
}
android {
namespace = "com.lxh.qingting_player"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId = "com.lxh.qingting_player"
// 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
// Uses the version code from pubspec.yaml. When using split APKs, 1000 * ABI_VERSION
// is added automatically by Flutter. (https://developer.android.com/studio/build/configure-apk-splits#configure-APK-versions)
// You can force using the value of versionCode by specifying the `-P force-version-code-ignoring-abi=true`
// flag during build.
versionCode = flutter.versionCode
versionName = flutter.versionName
// 与 main 分支保持一致:仅打包 arm64-v8a
ndk {
abiFilters.addAll(listOf("arm64-v8a"))
}
}
// AGP 9 不再允许在 AndroidManifest 里写 android:extractNativeLibs,
// 改为在这里声明,效果等价于原先的“强制提取 .so”
packaging {
jniLibs {
useLegacyPackaging = true
}
}
// AGP 9 默认关闭 resValue 生成,这里显式打开(debug 需要 "清听 Dev" 的应用名)
buildFeatures {
resValues = true
}
signingConfigs {
create("release") {
if (hasReleaseKeystore) {
keyAlias = keystoreProperties.getProperty("keyAlias")
keyPassword = keystoreProperties.getProperty("keyPassword")
storeFile = rootProject.file(keystoreProperties.getProperty("storeFile"))
storePassword = keystoreProperties.getProperty("storePassword")
}
}
}
buildTypes {
debug {
// 测试包与正式包并存安装:com.lxh.qingting_player.dev
// 说明:Android 包名每一段必须以字母开头,所以没法直接写 "_dev",
// 这里用 ".dev" 后缀,等价于给 debug 打上 dev 标记。
applicationIdSuffix = ".dev"
resValue("string", "app_name", "清听 Dev")
}
release {
resValue("string", "app_name", "清听")
// 有 key.properties 就用正式签名,否则回退 debug(仅本机调试用)
signingConfig = if (hasReleaseKeystore) {
signingConfigs.getByName("release")
} else {
signingConfigs.getByName("debug")
}
}
}
}
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}
flutter {
source = "../.."
}