2025-08-28 10:39:07 +08:00
|
|
|
|
// 应用插件
|
2025-08-27 15:30:45 +08:00
|
|
|
|
plugins {
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// Android应用程序插件,用于构建Android应用
|
2025-08-27 15:30:45 +08:00
|
|
|
|
id "com.android.application"
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// Kotlin Android插件,支持Kotlin语言开发
|
2025-08-27 15:30:45 +08:00
|
|
|
|
id "kotlin-android"
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// Flutter Gradle插件,用于集成Flutter框架
|
2025-08-27 15:30:45 +08:00
|
|
|
|
id "dev.flutter.flutter-gradle-plugin"
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 定义局部属性变量
|
2025-08-27 15:30:45 +08:00
|
|
|
|
def localProperties = new Properties()
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 获取local.properties文件
|
2025-08-27 15:30:45 +08:00
|
|
|
|
def localPropertiesFile = rootProject.file('local.properties')
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 如果local.properties文件存在,则加载其内容
|
2025-08-27 15:30:45 +08:00
|
|
|
|
if (localPropertiesFile.exists()) {
|
|
|
|
|
|
localPropertiesFile.withReader('UTF-8') { reader ->
|
|
|
|
|
|
localProperties.load(reader)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 从local.properties中获取Flutter版本代码,如果不存在则默认为'1'
|
2025-08-27 15:30:45 +08:00
|
|
|
|
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
|
|
|
|
|
if (flutterVersionCode == null) {
|
|
|
|
|
|
flutterVersionCode = '1'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 从local.properties中获取Flutter版本名称,如果不存在则默认为'1.0'
|
2025-08-27 15:30:45 +08:00
|
|
|
|
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
|
|
|
|
|
if (flutterVersionName == null) {
|
|
|
|
|
|
flutterVersionName = '1.0'
|
|
|
|
|
|
}
|
2025-08-28 16:01:38 +08:00
|
|
|
|
// 获取签名密码
|
|
|
|
|
|
def keystoreProperties = new Properties()
|
|
|
|
|
|
def keystorePropertiesFile = rootProject.file('key.properties')
|
|
|
|
|
|
if (keystorePropertiesFile.exists()) {
|
|
|
|
|
|
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
|
|
|
|
|
}
|
2025-08-27 15:30:45 +08:00
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// Android配置块
|
2025-08-27 15:30:45 +08:00
|
|
|
|
android {
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 应用程序的命名空间
|
2025-08-27 15:30:45 +08:00
|
|
|
|
namespace "com.example.starwork_flutter"
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 编译SDK版本,使用Flutter配置的版本
|
2025-08-27 15:30:45 +08:00
|
|
|
|
compileSdk flutter.compileSdkVersion
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// NDK版本,使用Flutter配置的版本
|
2025-08-27 15:30:45 +08:00
|
|
|
|
ndkVersion flutter.ndkVersion
|
|
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// Java编译选项
|
2025-08-27 15:30:45 +08:00
|
|
|
|
compileOptions {
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 源代码兼容性设置为Java 1.8
|
2025-08-27 15:30:45 +08:00
|
|
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 目标兼容性设置为Java 1.8
|
2025-08-27 15:30:45 +08:00
|
|
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// Kotlin编译选项
|
2025-08-27 15:30:45 +08:00
|
|
|
|
kotlinOptions {
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// JVM目标版本设置为1.8
|
2025-08-27 15:30:45 +08:00
|
|
|
|
jvmTarget = '1.8'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 源代码集配置
|
2025-08-27 15:30:45 +08:00
|
|
|
|
sourceSets {
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 添加Kotlin源代码目录
|
2025-08-27 15:30:45 +08:00
|
|
|
|
main.java.srcDirs += 'src/main/kotlin'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 默认配置
|
2025-08-27 15:30:45 +08:00
|
|
|
|
defaultConfig {
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 应用程序ID,唯一标识符
|
2025-08-27 15:30:45 +08:00
|
|
|
|
applicationId "com.example.starwork_flutter"
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 最小SDK版本,设置为25
|
|
|
|
|
|
minSdkVersion 25
|
|
|
|
|
|
// 目标SDK版本,设置为35
|
|
|
|
|
|
targetSdkVersion 35
|
|
|
|
|
|
// 版本代码,用于应用商店区分版本
|
2025-08-27 15:30:45 +08:00
|
|
|
|
versionCode flutterVersionCode.toInteger()
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 版本名称,用户可见的版本号
|
2025-08-27 15:30:45 +08:00
|
|
|
|
versionName flutterVersionName
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 设置支持的ABI架构
|
|
|
|
|
|
ndk {
|
|
|
|
|
|
// abiFilters "arm64-v8a"
|
2025-08-28 16:01:38 +08:00
|
|
|
|
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 👇 添加 signingConfigs
|
|
|
|
|
|
// 对应flavorizr.gradle中的 signingConfig 属性
|
|
|
|
|
|
signingConfigs {
|
|
|
|
|
|
debug {
|
|
|
|
|
|
// 使用默认 debug 签名(无需配置)
|
|
|
|
|
|
}
|
2025-09-05 14:55:38 +08:00
|
|
|
|
sky {
|
2025-08-28 16:01:38 +08:00
|
|
|
|
keyAlias keystoreProperties['sky.keyAlias']
|
|
|
|
|
|
keyPassword keystoreProperties['sky.keyPassword']
|
|
|
|
|
|
storeFile keystoreProperties['sky.storeFile'] ? file(keystoreProperties['sky.storeFile']) : null
|
|
|
|
|
|
storePassword keystoreProperties['sky.storePassword']
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-05 14:55:38 +08:00
|
|
|
|
xhj {
|
2025-08-28 16:01:38 +08:00
|
|
|
|
keyAlias keystoreProperties['xhj.keyAlias']
|
|
|
|
|
|
keyPassword keystoreProperties['xhj.keyPassword']
|
|
|
|
|
|
storeFile keystoreProperties['xhj.storeFile'] ? file(keystoreProperties['sky.storeFile']) : null
|
|
|
|
|
|
storePassword keystoreProperties['xhj.storePassword']
|
2025-08-28 10:39:07 +08:00
|
|
|
|
}
|
2025-08-27 15:30:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 构建类型配置
|
2025-08-27 15:30:45 +08:00
|
|
|
|
buildTypes {
|
2025-08-28 16:01:38 +08:00
|
|
|
|
debug {
|
2025-08-27 15:30:45 +08:00
|
|
|
|
signingConfig signingConfigs.debug
|
|
|
|
|
|
}
|
2025-08-28 16:01:38 +08:00
|
|
|
|
release {
|
|
|
|
|
|
// release 类型根据 flavor 使用不同签名
|
|
|
|
|
|
}
|
2025-08-27 15:30:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// Flutter配置块
|
2025-08-27 15:30:45 +08:00
|
|
|
|
flutter {
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// Flutter源代码路径
|
2025-08-27 15:30:45 +08:00
|
|
|
|
source '../..'
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-28 10:39:07 +08:00
|
|
|
|
// 依赖项配置
|
|
|
|
|
|
// 目前没有添加任何依赖项
|
2025-08-27 15:30:45 +08:00
|
|
|
|
dependencies {}
|
2025-08-28 11:27:32 +08:00
|
|
|
|
// ----- BEGIN flavorDimensions (autogenerated by flutter_flavorizr) -----
|
|
|
|
|
|
apply from: "flavorizr.gradle"
|
|
|
|
|
|
// ----- END flavorDimensions (autogenerated by flutter_flavorizr) -----
|