优化:增加ABI配置(按CPU架构分别打包)

This commit is contained in:
pppscn 2022-01-28 21:33:06 +08:00
parent ee740829d8
commit 02c0189d28

View File

@ -27,6 +27,9 @@ android {
versionCode versionProps['versionCode'].toInteger()
versionName versionProps['versionName']
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
//ndk {
// abiFilters 'armeabi-v7a', 'x86_64'
//}
}
lintOptions {
checkReleaseBuilds false
@ -47,31 +50,40 @@ android {
}
buildTypes {
release {
//minifyEnabled true
minifyEnabled false
//shrinkResources true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
debug {
//minifyEnabled true
minifyEnabled false
//shrinkResources true
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
}
//apk file name
android.applicationVariants.all { variant ->
variant.outputs.all {
//def date = new Date().format("yyyyMMdd" , TimeZone.getTimeZone("Asia/Shanghai"))
def date = new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08"))
if (variant.buildType.name == 'debug') {
outputFileName = "SmsForwarder_debug_${date}_${versionName}.apk"
}
if (variant.buildType.name == 'release') {
outputFileName = "SmsForwarder_release_${date}_${versionName}.apk"
}
//ABI配置CPU架构分别打包
splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk true
}
}
def abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86': 3, 'x86_64': 4, 'universal': 5]
android.applicationVariants.all { variant ->
// Assigns a different version code for each output APK.
variant.outputs.each {
output ->
def date = new Date().format("yyyyMMdd", TimeZone.getTimeZone("GMT+08"))
def abiName = output.getFilter(com.android.build.OutputFile.ABI)
if (abiName == null) abiName = "universal"
output.versionCodeOverride = abiCodes.get(abiName, 0) * 10000 + variant.versionCode
output.outputFileName = "SmsForwarder_${variant.name}_${versionName}_${output.versionCodeOverride}_${date}_${abiName}.apk"
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
@ -151,7 +163,7 @@ dependencies {
//SDK
implementation 'com.umeng.umsdk:common:9.4.6'//
implementation 'com.umeng.umsdk:asms:1.6.0'// asms包依赖必选
//implementation 'com.umeng.umsdk:apm:1.5.2'// SDKcrash数据请一定集成
implementation 'com.umeng.umsdk:apm:1.5.2'// SDKcrash数据请一定集成
//implementation 'com.umeng.umsdk:abtest:1.0.0'//使U-App中ABTest能力
//XUpdate
@ -173,8 +185,10 @@ dependencies {
//AndroidAsync
implementation 'com.koushikdutta.async:androidasync:3.1.0'
//https://github.com/getActivity/ToastUtils
implementation 'com.github.getActivity:ToastUtils:10.3'
//https://github.com/getActivity/XXPermissions
//implementation 'com.github.getActivity:XXPermissions:13.2'
implementation 'com.github.getActivity:XXPermissions:13.2'
//jetty
implementation "org.eclipse.jetty:jetty-server:9.2.30.v20200428"