build: update agp android gradle version

update agp to 8.13.2,update gradle to 8.13,add build.gradle namespace
This commit is contained in:
2026-06-24 19:09:30 +08:00
parent 6c10b094ce
commit 9e8dbd3566
8 changed files with 155 additions and 110 deletions

View File

@@ -9,23 +9,10 @@ static def releaseTime() {
}
android {
//Android Studio 4.0 之后使用这个但是会把jar打包进apk
// gradle.projectsEvaluated {
// tasks.withType(JavaCompile) {
// Set<File> fileSet = options.bootstrapClasspath.getFiles()
// List<File> newFileList = new ArrayList<>();
// //JAVA语法可连续调用输入参数建议为相对路径
// newFileList.add(new File("libs/framework.jar"))
// //最后将原始参数添加
// newFileList.addAll(fileSet)
// options.bootstrapClasspath = files(
// newFileList.toArray()
// )
// }
// }
namespace "com.aoleyun.sn"
compileSdkVersion 29
buildToolsVersion "30.0.3"
buildToolsVersion "36.0.0"
defaultConfig {
applicationId "com.aoleyun.sn"
@@ -44,6 +31,13 @@ android {
// 还可以添加 'armeabi', 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64', 'mips', 'mips64'
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
buildConfigField "String", "ROOT_URL", '"https://led.aoleyun.cn/api/"'
buildConfigField "String", "SCREEN_BASE_URL", '"https://led.aoleyun.cn:2018/"'
buildConfigField "String", "SCREEN_URL", '"https://led.aoleyun.cn:2018/wm/is_online"'
@@ -51,22 +45,17 @@ android {
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
dataBinding {
enabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
dataBinding true
buildConfig true
aidl true
}
externalNativeBuild {
cmake {
path file('CMakeLists.txt')
@@ -226,6 +215,15 @@ android {
v2SigningEnabled true
}
BCM310 {
storeFile file("keystore/BCM310.keystore")
storePassword "123456"
keyAlias "bcm310"
keyPassword "123456"
v1SigningEnabled true
v2SigningEnabled true
}
P50 {
storeFile file("keystore/P50TD.jks")
storePassword "123456"
@@ -408,6 +406,20 @@ android {
buildConfigField "String", "platform", '"HL500"'
}
BCM310Debug.initWith(debug)
BCM310Debug {
versionNameSuffix "-debug"
debuggable true
signingConfig signingConfigs.BCM310
buildConfigField "String", "platform", '"HL500"'
}
BCM310Release.initWith(release)
BCM310Release {
signingConfig signingConfigs.BCM310
buildConfigField "String", "platform", '"HL500"'
}
AiUduDebug.initWith(debug)
AiUduDebug {
versionNameSuffix "-debug"
@@ -654,18 +666,9 @@ android {
debuggable true
versionNameSuffix "-debug"
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//Zipalign优化
zipAlignEnabled true
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null) {
def fileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType.name}.apk"
output.outputFileName = fileName
}
}
}
signingConfig signingConfigs.mtk
buildConfigField "String", "platform", '"MTK"'
}
@@ -674,23 +677,30 @@ android {
//混淆
minifyEnabled false
//前一部分代表系统默认的android程序的混淆文件该文件已经包含了基本的混淆声明后一个文件是自己的定义混淆文件
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
//Zipalign优化
zipAlignEnabled true
applicationVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null) {
def fileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType.name}.apk"
output.outputFileName = fileName
}
}
}
signingConfig signingConfigs.mtk
buildConfigField "String", "platform", '"MTK"'
}
}
// Add application variant configuration here instead
applicationVariants.all { variant ->
variant.outputs.each { output ->
def buildType = variant.buildType.name
def fileName = ""
if (buildType.contains("debug")) {
fileName = "${appName()}_V${defaultConfig.versionName}_${releaseTime()}.apk"
} else {
fileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk"
}
output.outputFileName = fileName
}
}
}
dependencies {
@@ -792,27 +802,37 @@ dependencies {
implementation 'com.github.getActivity:Toaster:12.6'
}
preBuild {
doLast {
def imlFile = file(project.name + ".iml")
// def imlFile = file("..\\.idea\\modules\\" + project.name + "\\" + rootProject.name + "." + project.name + ".iml")
println 'Change ' + project.name + '.iml order'
try {
def parsedXml = (new XmlParser()).parse(imlFile)
def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
parsedXml.component[1].remove(jdkNode)
def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
println 'what' + sdkString
new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
} catch (FileNotFoundException e) {
// nop, iml not found
println "no iml found"
}
// 在 dependencies 之后添加
project.afterEvaluate {
android.applicationVariants.all { variant ->
variant.javaCompileProvider.get().options.bootstrapClasspath = files(
file('libs/framework.jar'),
android.getBootClasspath()
)
}
//https://www.pianshen.com/article/93481144911/
//https://blog.csdn.net/dhl_1986/article/details/102856026
//https://blog.csdn.net/zhonghe1114/article/details/80923730
//https://blog.csdn.net/u014175785/article/details/116235760
//使用系统编译后的framework.jar
}
//preBuild {
// doLast {
// def imlFile = file(project.name + ".iml")
//// def imlFile = file("..\\.idea\\modules\\" + project.name + "\\" + rootProject.name + "." + project.name + ".iml")
// println 'Change ' + project.name + '.iml order'
// try {
// def parsedXml = (new XmlParser()).parse(imlFile)
// def jdkNode = parsedXml.component[1].orderEntry.find { it.'@type' == 'jdk' }
// parsedXml.component[1].remove(jdkNode)
// def sdkString = "Android API " + android.compileSdkVersion.substring("android-".length()) + " Platform"
// println 'what' + sdkString
// new Node(parsedXml.component[1], 'orderEntry', ['type': 'jdk', 'jdkName': sdkString, 'jdkType': 'Android SDK'])
// groovy.xml.XmlUtil.serialize(parsedXml, new FileOutputStream(imlFile))
// } catch (FileNotFoundException e) {
// // nop, iml not found
// println "no iml found"
// }
// }
// //https://www.pianshen.com/article/93481144911/
// //https://blog.csdn.net/dhl_1986/article/details/102856026
// //https://blog.csdn.net/zhonghe1114/article/details/80923730
// //https://blog.csdn.net/u014175785/article/details/116235760
// //使用系统编译后的framework.jar
//}