372 lines
16 KiB
Groovy
Executable File
372 lines
16 KiB
Groovy
Executable File
def localProperties = new Properties()
|
||
def localPropertiesFile = rootProject.file('local.properties')
|
||
if (localPropertiesFile.exists()) {
|
||
localPropertiesFile.withReader('UTF-8') { reader ->
|
||
localProperties.load(reader)
|
||
}
|
||
}
|
||
|
||
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
||
if (flutterRoot == null) {
|
||
// throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||
throw new Exception("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
|
||
}
|
||
|
||
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
||
if (flutterVersionCode == null) {
|
||
flutterVersionCode = '1'
|
||
}
|
||
|
||
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
||
if (flutterVersionName == null) {
|
||
flutterVersionName = '1.0'
|
||
}
|
||
|
||
apply plugin: 'com.android.application'
|
||
//<com>
|
||
apply plugin: 'com.google.gms.google-services'
|
||
//</com>
|
||
apply plugin: 'kotlin-android'
|
||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||
apply plugin: 'com.android.application'
|
||
//apply plugin: 'android-junk-code'
|
||
apply plugin: 'com.huawei.agconnect'
|
||
apply from: 'and_res_guard.gradle'
|
||
|
||
//androidJunkCode {
|
||
// variantConfig {
|
||
// release {
|
||
// //注意:这里的release是变体名称,如果没有设置productFlavors就是buildType名称,如果有设置productFlavors就是flavor+buildType,例如(freeRelease、proRelease)
|
||
// packageBase = "cn.hx.plugin.ui" //生成java类根包名
|
||
// packageCount = 30 //生成包数量
|
||
// activityCountPerPackage = 3 //每个包下生成Activity类数量
|
||
// excludeActivityJavaFile = false
|
||
// //是否排除生成Activity的Java文件,默认false(layout和写入AndroidManifest.xml还会执行),主要用于处理类似神策全埋点编译过慢问题
|
||
// otherCountPerPackage = 50 //每个包下生成其它类的数量
|
||
// methodCountPerClass = 20 //每个类下生成方法数量
|
||
// resPrefix = "junk_" //生成的layout、drawable、string等资源名前缀
|
||
// drawableCount = 300 //生成drawable资源数量
|
||
// stringCount = 300 //生成string数量
|
||
// }
|
||
// }
|
||
//}
|
||
|
||
android {
|
||
signingConfigs {
|
||
// 这里“debug”不是一个自定义变量,而是一个特定的关键词,凡是使用--debug模式,都会引用到这里
|
||
// 目前看来,debug模式没办法在buildTypes里面按flavors指定编译签名,所有口味的debug模式只能用同一个签名
|
||
debug {
|
||
storeFile file("starlock.keystore")
|
||
storePassword '123456'
|
||
keyAlias = 'starlock'
|
||
keyPassword '123456'
|
||
// storeFile file("xhj.jks")
|
||
// storePassword 'xhj8872'
|
||
// keyAlias = 'upload'
|
||
// keyPassword 'xhj8872'
|
||
}
|
||
sky {
|
||
// CN=Unknown, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown, C=Unknown
|
||
storeFile file("sky.jks")
|
||
storePassword 'sky2028'
|
||
keyAlias = 'upload'
|
||
keyPassword 'sky2028'
|
||
}
|
||
xhj {
|
||
storeFile file("xhj.jks")
|
||
storePassword 'xhj8872'
|
||
keyAlias = 'upload'
|
||
keyPassword 'xhj8872'
|
||
}
|
||
|
||
xhj_bundle {
|
||
storeFile file("xhj_bundle.jks")
|
||
storePassword 'xhj8872'
|
||
keyAlias = 'xhj'
|
||
keyPassword 'xhj8872'
|
||
}
|
||
}
|
||
|
||
// ----- BEGIN flavorDimensions (autogenerated by flutter_flavorizr) -----
|
||
flavorDimensions "flavor-type"
|
||
|
||
productFlavors {
|
||
local {
|
||
dimension "flavor-type"
|
||
applicationId "com.starlock.lock.local"
|
||
signingConfig signingConfigs.debug
|
||
resValue "string", "app_name", "Star Lock"
|
||
manifestPlaceholders.JPUSH_PKGNAME = "com.starlock.lock.local"
|
||
}
|
||
dev {
|
||
dimension "flavor-type"
|
||
applicationId "com.starlock.lock.dev"
|
||
signingConfig signingConfigs.debug
|
||
resValue "string", "app_name", "Star Lock"
|
||
manifestPlaceholders.JPUSH_PKGNAME = "com.starlock.lock.dev"
|
||
}
|
||
pre {
|
||
dimension "flavor-type"
|
||
applicationId "com.starlock.lock.pre"
|
||
signingConfig signingConfigs.debug
|
||
resValue "string", "app_name", "Star Lock-P"
|
||
manifestPlaceholders.JPUSH_PKGNAME = "com.starlock.lock.pre"
|
||
}
|
||
sky {
|
||
dimension "flavor-type"
|
||
applicationId "com.skychip.lock"
|
||
signingConfig signingConfigs.sky
|
||
resValue "string", "app_name", "TTLock Pro"
|
||
manifestPlaceholders = [
|
||
JPUSH_PKGNAME : "com.skychip.lock",
|
||
JPUSH_APPKEY : "7ff37d174c1a568a89e98dad",//--skyAppKey
|
||
JPUSH_CHANNEL : "flutter_channel",
|
||
XIAOMI_APPID : "MI-2882303761520287291",
|
||
XIAOMI_APPKEY : "MI-5352028744291",
|
||
OPPO_APPKEY : "OP-ccae67a4a8c1470a8350b0d6a89f8105",
|
||
OPPO_APPID : "OP-31586713",
|
||
OPPO_APPSECRET: "OP-2339389233094ca297de7b10213f7bd8",
|
||
VIVO_APPKEY : "6a18657357d176364a91f50e4c9cd7c4",
|
||
VIVO_APPID : "105724810",
|
||
HONOR_APPID : "104437184",
|
||
]
|
||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules-sky.pro'
|
||
}
|
||
sky_pre {
|
||
dimension "flavor-type"
|
||
applicationId "com.skychip.lock.pre"
|
||
signingConfig signingConfigs.sky
|
||
resValue "string", "app_name", "TTLock Pro-P"
|
||
manifestPlaceholders.JPUSH_PKGNAME = "com.skychip.lock.pre"
|
||
}
|
||
sky_dev {
|
||
dimension "flavor-type"
|
||
applicationId "com.skychip.lock.dev"
|
||
signingConfig signingConfigs.sky
|
||
resValue "string", "app_name", "TTLock Pro"
|
||
manifestPlaceholders.JPUSH_PKGNAME = "com.skychip.lock.dev"
|
||
}
|
||
xhj {
|
||
dimension "flavor-type"
|
||
applicationId "com.xhjcn.lock"
|
||
signingConfig signingConfigs.xhj
|
||
resValue "string", "app_name", "Star Lock"
|
||
manifestPlaceholders = [
|
||
JPUSH_PKGNAME : "com.xhjcn.lock",
|
||
JPUSH_APPKEY : "251fc8074820d122b6de58d2",//--鑫泓佳AppKey
|
||
JPUSH_CHANNEL : "flutter_channel",
|
||
XIAOMI_APPID : "MI-2882303761520314939",
|
||
XIAOMI_APPKEY : "MI-5312031456939",
|
||
OPPO_APPKEY : "OP-47f668c9943248118502aa58d066393b",
|
||
OPPO_APPID : "OP-31726001",
|
||
OPPO_APPSECRET: "OP-05723986bba64183a71530b496922450",
|
||
VIVO_APPKEY : "75fe8e570425b714e08d0390b14797cb",
|
||
VIVO_APPID : "105752244",
|
||
HONOR_APPID : "104458196",
|
||
]
|
||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules-xhj.pro'
|
||
}
|
||
|
||
xhj_bundle {
|
||
dimension "flavor-type"
|
||
applicationId "ltd.xhjcn.lock"
|
||
|
||
signingConfig signingConfigs.xhj_bundle
|
||
resValue "string", "app_name", "Star Lock"
|
||
manifestPlaceholders = [
|
||
JPUSH_PKGNAME: "ltd.xhjcn.lock",
|
||
JPUSH_APPKEY : "5ccdb9b8d3faaae66ba5d02e",
|
||
JPUSH_CHANNEL: "flutter_channel",
|
||
]
|
||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules-xhj.pro'
|
||
}
|
||
|
||
xhj_pre {
|
||
dimension "flavor-type"
|
||
applicationId "com.xhjcn.lock.pre"
|
||
signingConfig signingConfigs.xhj
|
||
resValue "string", "app_name", "Star Lock-P"
|
||
manifestPlaceholders.JPUSH_PKGNAME = "com.xhjcn.lock.pre"
|
||
}
|
||
xhj_dev {
|
||
dimension "flavor-type"
|
||
applicationId "com.xhjcn.lock.dev"
|
||
signingConfig signingConfigs.xhj
|
||
resValue "string", "app_name", "Star Lock"
|
||
manifestPlaceholders.JPUSH_PKGNAME = "com.xhjcn.lock.dev"
|
||
}
|
||
}
|
||
|
||
// ----- END flavorDimensions (autogenerated by flutter_flavorizr) -----
|
||
|
||
compileSdkVersion flutter.compileSdkVersion
|
||
ndkVersion flutter.ndkVersion
|
||
|
||
lintOptions {
|
||
checkReleaseBuilds false
|
||
abortOnError false
|
||
}
|
||
|
||
|
||
compileOptions {
|
||
sourceCompatibility JavaVersion.VERSION_1_8
|
||
targetCompatibility JavaVersion.VERSION_1_8
|
||
}
|
||
|
||
kotlinOptions {
|
||
jvmTarget = '1.8'
|
||
}
|
||
|
||
sourceSets {
|
||
main.java.srcDirs += 'src/main/kotlin'
|
||
}
|
||
|
||
defaultConfig {
|
||
applicationId "com.skychip.lock"
|
||
// You can update the following values to match your application needs.
|
||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
|
||
minSdkVersion 25
|
||
targetSdkVersion 35
|
||
versionCode flutterVersionCode.toInteger()
|
||
versionName flutterVersionName
|
||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||
|
||
// 为减少体积,使用不同架构分包发布编译选项 flutter build apk --split-per-abi
|
||
// 所以需要禁用ndk在同一个个包中包含多个架构
|
||
// 但是禁用NDK配置,又无法使用flutter run 命令了,因为编译完成它按照名称匹配找不到.apk包
|
||
ndk {
|
||
//设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
|
||
// abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
|
||
|
||
|
||
// 参考魅族平台的公告,得知在2023年1月商店就可以只需要64位应用即可
|
||
// 这说明32位是很老很老的平台,我们的flutter或者说我们的项目本来就兼容不了老平台,架构兼容也没必要
|
||
abiFilters "arm64-v8a"
|
||
}
|
||
|
||
manifestPlaceholders = [
|
||
JPUSH_PKGNAME : "这里不重要,在口味配置",
|
||
//JPush 上注册的包名对应的 Appkey.
|
||
// JPUSH_APPKEY : "7ff37d174c1a568a89e98dad",//--skyAppKey
|
||
JPUSH_APPKEY : "default",//--鑫泓佳AppKey
|
||
JPUSH_CHANNEL : "default",
|
||
|
||
//若不集成厂商通道,可直接跳过以下配置
|
||
//以下为sky的配置
|
||
// XIAOMI_APPID : "MI-2882303761520287291",
|
||
// XIAOMI_APPKEY : "MI-5352028744291",
|
||
//以下均为鑫泓佳的配置
|
||
XIAOMI_APPID : "default",
|
||
XIAOMI_APPKEY : "default",
|
||
OPPO_APPKEY : "default",
|
||
OPPO_APPID : "default",
|
||
OPPO_APPSECRET: "default",
|
||
VIVO_APPKEY : "default",
|
||
VIVO_APPID : "default",
|
||
HONOR_APPID : "default",
|
||
]
|
||
splits {
|
||
abi {
|
||
enable true
|
||
reset()
|
||
// 参考魅族平台的公告,得知在2023年1月商店就可以只需要64位应用即可
|
||
// 这说明32位是很老很老的平台,我们的flutter或者说我们的项目本来就兼容不了老平台,架构兼容也没必要
|
||
// include "armeabi", "armeabi-v7a", "arm64-v8a", "x86","x86_64"
|
||
// include "arm64-v8a"
|
||
universalApk false
|
||
}
|
||
}
|
||
}
|
||
|
||
buildTypes {
|
||
debug {
|
||
// 高德地图导致release编译模式下应用闪退,根据:[高德地图在Debug模式下运行正常但是打Release包时则闪退解决办法](https://blog.csdn.net/weixin_39370093/article/details/109631210)
|
||
// 为release模式设置混淆可以解决地图闪退问题
|
||
// 真实的解决办法
|
||
minifyEnabled false
|
||
shrinkResources false
|
||
productFlavors.local.signingConfig signingConfigs.debug
|
||
productFlavors.dev.signingConfig signingConfigs.debug
|
||
productFlavors.pre.signingConfig signingConfigs.debug
|
||
productFlavors.sky.signingConfig signingConfigs.sky
|
||
productFlavors.sky_dev.signingConfig signingConfigs.sky
|
||
productFlavors.sky_pre.signingConfig signingConfigs.sky
|
||
productFlavors.xhj.signingConfig signingConfigs.xhj
|
||
productFlavors.xhj_dev.signingConfig signingConfigs.xhj
|
||
productFlavors.xhj_pre.signingConfig signingConfigs.xhj
|
||
}
|
||
release {
|
||
// 高德地图导致release编译模式下应用闪退,根据:[高德地图在Debug模式下运行正常但是打Release包时则闪退解决办法](https://blog.csdn.net/weixin_39370093/article/details/109631210)
|
||
// 为release模式设置混淆可以解决地图闪退问题
|
||
// 真实的解决办法
|
||
minifyEnabled true
|
||
shrinkResources true
|
||
productFlavors.local.signingConfig signingConfigs.debug
|
||
productFlavors.dev.signingConfig signingConfigs.debug
|
||
productFlavors.pre.signingConfig signingConfigs.debug
|
||
productFlavors.sky.signingConfig signingConfigs.sky
|
||
productFlavors.sky_dev.signingConfig signingConfigs.sky
|
||
productFlavors.sky_pre.signingConfig signingConfigs.sky
|
||
productFlavors.xhj.signingConfig signingConfigs.xhj
|
||
productFlavors.xhj_dev.signingConfig signingConfigs.xhj
|
||
productFlavors.xhj_pre.signingConfig signingConfigs.xhj
|
||
}
|
||
}
|
||
|
||
applicationVariants.all { variant ->
|
||
variant.outputs.all {
|
||
outputFileName = "app-starlock-${variant.buildType.name}-${variant.flavorName}-${defaultConfig.versionName}.apk"
|
||
}
|
||
}
|
||
}
|
||
|
||
flutter {
|
||
source '../..'
|
||
}
|
||
|
||
dependencies {
|
||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
||
// implementation('com.amap.api:location:5.6.0')
|
||
// implementation('com.amap.api:3dmap:8.1.0')
|
||
// implementation('com.amap.api:3dmap-location-search:latest.integration')
|
||
|
||
implementation 'cn.jiguang.sdk:jpush:5.2.3'
|
||
// 接入华为厂商
|
||
implementation 'com.huawei.agconnect:agconnect-core:1.8.1.300'
|
||
implementation 'com.huawei.hms:push:6.12.0.300'
|
||
implementation 'cn.jiguang.sdk.plugin:huawei:5.2.3'
|
||
// 接入小米厂商
|
||
implementation 'cn.jiguang.sdk.plugin:xiaomi:5.2.3'
|
||
//接入OPPO厂商
|
||
implementation 'cn.jiguang.sdk.plugin:oppo:5.2.3'
|
||
//引入 libs 中的 aar,如果项目中有此依赖不需要重复引用
|
||
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
|
||
//OPPO 3.1.0 aar 及其以上版本需要添加以下依赖
|
||
implementation 'com.google.code.gson:gson:2.6.2'
|
||
implementation 'commons-codec:commons-codec:1.6'
|
||
implementation 'androidx.annotation:annotation:1.1.0'
|
||
// 接入荣耀厂商
|
||
implementation 'cn.jiguang.sdk.plugin:honor:5.2.3'
|
||
//需要单独引入荣耀厂商 aar ,请下载官网 SDK 包并把 jpush-android-xxx-release/third-push/honor/libs 下的 aar 文件单独拷贝一份到应用 module/libs 下
|
||
// implementation(name: 'HiPushSDK-7.0.61.303', ext: 'aar')
|
||
//接入 VIVO 厂商
|
||
implementation 'cn.jiguang.sdk.plugin:vivo:5.2.3'
|
||
|
||
// Umeng统计
|
||
//<cn>
|
||
implementation 'com.umeng.umsdk:common:9.7.9'
|
||
implementation 'com.umeng.umsdk:asms:1.8.5'
|
||
//</cn>
|
||
//<com>
|
||
// implementation 'cn.jiguang.sdk.plugin:fcm:5.2.3'
|
||
// implementation 'com.google.firebase:firebase-messaging:23.0.5'
|
||
//</com>
|
||
|
||
//FCM云消息与极光FCM插件
|
||
implementation 'com.google.firebase:firebase-messaging:23.2.1'
|
||
implementation 'cn.jiguang.sdk.plugin:fcm:5.2.2'
|
||
|
||
|
||
|
||
}
|