build: 没修改之前的代码升级agp8
This commit is contained in:
157
app/build.gradle
157
app/build.gradle
@@ -1,31 +1,18 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: "com.tencent.android.tpns"
|
||||
|
||||
static def appName() {
|
||||
return "FLYSN"
|
||||
}
|
||||
|
||||
static def releaseTime() {
|
||||
return new Date().format("yyyyMMdd-HHmmss", TimeZone.getDefault())
|
||||
return new Date().format("yyyyMMdd_HHmmss", TimeZone.getDefault())
|
||||
}
|
||||
|
||||
android {
|
||||
// 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.fuying.sn"
|
||||
|
||||
compileSdkVersion 29
|
||||
buildToolsVersion "29.0.3"
|
||||
buildToolsVersion "36.0.0"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.fuying.sn"
|
||||
@@ -41,45 +28,54 @@ android {
|
||||
// 还可以添加 'x86', 'x86_64', 'mips', 'mips64'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
includeCompileClasspath true
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
}
|
||||
|
||||
dataBinding {
|
||||
enabled true
|
||||
// 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
|
||||
}
|
||||
|
||||
manifestPlaceholders = [
|
||||
XG_ACCESS_ID : "1500031216",
|
||||
XG_ACCESS_KEY: "A1HBG2922B9Z",
|
||||
]
|
||||
buildConfigField "String", "SCREEN_URL", '"https://as.fuyingy.com:3018/wm/is_online"'
|
||||
buildConfigField "String", "WEBSOCKET_URL", '"wss://47.111.23.154:3018"'
|
||||
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
|
||||
buildFeatures {
|
||||
dataBinding true
|
||||
buildConfig true
|
||||
aidl true
|
||||
}
|
||||
|
||||
//多版本
|
||||
productFlavors {
|
||||
// beta {
|
||||
// flavorDimensions "default"
|
||||
// versionCode 33
|
||||
// versionName "4.2"
|
||||
// }
|
||||
beta {
|
||||
flavorDimensions "default"
|
||||
versionCode 89
|
||||
versionName "4.3"
|
||||
// applicationId "com.fuying.sn"
|
||||
applicationId "com.fying.sntest"
|
||||
|
||||
buildConfigField "String", "ROOT_URL", '"https://fxyapi.17hxg.com/android/"'
|
||||
buildConfigField "String", "SCREEN_URL", '"https://fxyapi.17hxg.com:3018/wm/is_online"'
|
||||
// buildConfigField "String", "WEBSOCKET_URL", '"wss://47.111.23.154:3018"'
|
||||
}
|
||||
|
||||
official {
|
||||
flavorDimensions "default"
|
||||
versionCode 87
|
||||
versionName "3.4.7"
|
||||
applicationId "com.fuying.sn"
|
||||
|
||||
buildConfigField "String", "ROOT_URL", '"https://as.fuyingy.com/android/"'
|
||||
buildConfigField "String", "SCREEN_URL", '"https://as.fuyingy.com:3018/wm/is_online"'
|
||||
// buildConfigField "String", "WEBSOCKET_URL", '"wss://47.111.23.154:3018"'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -450,48 +446,28 @@ android {
|
||||
debug {
|
||||
buildConfigField "String", "platform", '"MTK"'
|
||||
versionNameSuffix "-debug"
|
||||
//Zipalign优化
|
||||
zipAlignEnabled true
|
||||
minifyEnabled false
|
||||
signingConfig signingConfigs.mtk
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
if (outputFile != null) {
|
||||
def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk"
|
||||
output.outputFileName = fileName
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
release {
|
||||
buildConfigField "String", "platform", '"MTK"'
|
||||
//Zipalign优化
|
||||
zipAlignEnabled true
|
||||
//混淆
|
||||
minifyEnabled false
|
||||
//前一部分代表系统默认的android程序的混淆文件,该文件已经包含了基本的混淆声明,后一个文件是自己的定义混淆文件
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
//签名
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.mtk
|
||||
// 将release版本的包名重命名,加上版本及日期
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def outputFile = ""
|
||||
if (outputFile != null) {
|
||||
def fileName = "${appName()}-${variant.versionCode}-V${variant.versionName}-${releaseTime()}-${buildType.name}.apk"
|
||||
output.outputFileName = new File(outputFile, fileName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
// Add application variant configuration here instead
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.each { output ->
|
||||
def buildType = variant.buildType.name
|
||||
if (buildType.contains("debug")) {
|
||||
output.outputFileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}_debug.apk"
|
||||
} else {
|
||||
output.outputFileName = "${appName()}_${variant.versionCode}_V${variant.versionName}_${releaseTime()}_${buildType}.apk"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,8 +517,6 @@ dependencies {
|
||||
implementation 'com.tencent:mmkv-static:1.2.13'
|
||||
//bugly
|
||||
implementation 'com.tencent.bugly:crashreport:4.1.9.2'
|
||||
//腾讯移动推送 TPNS
|
||||
implementation 'com.tencent.tpns:tpns:1.4.4.2-release'
|
||||
//阿里云推送
|
||||
implementation 'com.aliyun.ams:alicloud-android-push:3.8.0'
|
||||
//百度地图
|
||||
@@ -563,23 +537,28 @@ dependencies {
|
||||
// implementation 'com.hjq:xxpermissions:6.0'
|
||||
}
|
||||
|
||||
preBuild {
|
||||
doLast {
|
||||
def imlFile = file(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()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register('deleteAppSourceWhiteList', Exec) {
|
||||
// Windows 系统使用 cmd /c, Mac/Linux 使用 sh -c
|
||||
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
||||
commandLine 'cmd', '/c', 'adb', 'shell', 'settings', 'delete', 'system', 'app_source_white_list'
|
||||
} else {
|
||||
commandLine 'adb', 'shell', 'settings', 'delete', 'system', 'app_source_white_list'
|
||||
}
|
||||
|
||||
// 即使命令执行失败也不中断构建(可选,防止因为没连手机导致编译失败)
|
||||
ignoreExitValue = true
|
||||
|
||||
doLast {
|
||||
println "ADB command executed: settings delete system app_source_white_list"
|
||||
}
|
||||
//https://www.pianshen.com/article/93481144911/
|
||||
//使用系统编译后的framework.jar
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user