function adapt
This commit is contained in:
+109
-8
@@ -1,4 +1,5 @@
|
||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.androidApplication)
|
||||
@@ -9,31 +10,108 @@ plugins {
|
||||
kotlin {
|
||||
compilerOptions {
|
||||
jvmTarget.set(JvmTarget.JVM_11)
|
||||
freeCompilerArgs.add("-Xexpect-actual-classes")
|
||||
}
|
||||
}
|
||||
|
||||
val appVersionCode = 20001
|
||||
val appVersionName = "2.0.0.01"
|
||||
|
||||
val taskNames = gradle.startParameter.taskNames
|
||||
val isApkRelease = taskNames.any { it.contains("assembleRelease", ignoreCase = true) }
|
||||
val isAabRelease = taskNames.any { it.contains("bundleRelease", ignoreCase = true) }
|
||||
|
||||
val keystoreProperties = Properties()
|
||||
if (isApkRelease || isAabRelease) {
|
||||
val keystorePropertiesFile = file("key.properties")
|
||||
if (!keystorePropertiesFile.exists()) {
|
||||
error("release 模式需要在 androidApp 目录下创建 key.properties(可参考 key.properties.example)")
|
||||
}
|
||||
keystorePropertiesFile.inputStream().use { keystoreProperties.load(it) }
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "top.zhushenwudi.llmp"
|
||||
namespace = "com.zhushenwudi.lovelivemusicplayer"
|
||||
compileSdk = libs.versions.android.compileSdk.get().toInt()
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "top.zhushenwudi.llmp"
|
||||
applicationId = "com.zhushenwudi.lovelivemusicplayer"
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
targetSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
versionCode = 1
|
||||
versionName = "0.2.0-phaseb"
|
||||
versionCode = appVersionCode
|
||||
versionName = appVersionName
|
||||
}
|
||||
|
||||
splits {
|
||||
abi {
|
||||
isEnable = isApkRelease
|
||||
reset()
|
||||
include("armeabi-v7a", "arm64-v8a")
|
||||
isUniversalApk = false
|
||||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
if (isApkRelease || isAabRelease) {
|
||||
create("release") {
|
||||
keyAlias = keystoreProperties.getProperty("keyAlias")
|
||||
keyPassword = keystoreProperties.getProperty("storePassword")
|
||||
storePassword = keystoreProperties.getProperty("keyPassword")
|
||||
val storePath = if (isAabRelease) {
|
||||
keystoreProperties.getProperty("aabStoreFile")
|
||||
} else {
|
||||
keystoreProperties.getProperty("apkStoreFile")
|
||||
}
|
||||
storeFile = file(storePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
getByName("debug") {
|
||||
isMinifyEnabled = false
|
||||
isDebuggable = true
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro",
|
||||
)
|
||||
}
|
||||
getByName("release") {
|
||||
isMinifyEnabled = true
|
||||
isShrinkResources = true
|
||||
if (isApkRelease || isAabRelease) {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
proguardFiles(
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro",
|
||||
)
|
||||
// ABI 分包开启时不能再写 ndk.abiFilters,否则 AGP 会报冲突。
|
||||
if (!isApkRelease) {
|
||||
ndk {
|
||||
//noinspection ChromeOsAbiSupport
|
||||
abiFilters += listOf("armeabi-v7a", "arm64-v8a")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
packaging {
|
||||
resources {
|
||||
excludes += "/META-INF/{AL2.0,LGPL2.1}"
|
||||
}
|
||||
dex {
|
||||
useLegacyPackaging = true
|
||||
}
|
||||
jniLibs {
|
||||
useLegacyPackaging = true
|
||||
}
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
getByName("release") {
|
||||
isMinifyEnabled = false
|
||||
}
|
||||
lint {
|
||||
abortOnError = false
|
||||
checkReleaseBuilds = false
|
||||
disable += "InvalidPackage"
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
@@ -42,6 +120,27 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
base.archivesName.set("LLMP_v$appVersionName")
|
||||
|
||||
afterEvaluate {
|
||||
tasks.findByName("assembleRelease")?.doLast {
|
||||
val apkRoot = layout.buildDirectory.dir("outputs/apk/release").get().asFile
|
||||
if (!apkRoot.exists()) return@doLast
|
||||
apkRoot.walkTopDown().maxDepth(2).filter { it.isFile && it.extension == "apk" }.forEach { apk ->
|
||||
val shortAbi = when {
|
||||
"arm64-v8a" in apk.name -> "v8a"
|
||||
"armeabi-v7a" in apk.name -> "v7a"
|
||||
else -> null
|
||||
} ?: return@forEach
|
||||
val target = apk.resolveSibling("LLMP_v${appVersionName}_${shortAbi}.apk")
|
||||
if (apk.canonicalFile != target.canonicalFile) {
|
||||
apk.copyTo(target, overwrite = true)
|
||||
apk.delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(projects.composeApp)
|
||||
implementation(projects.shared)
|
||||
@@ -57,10 +156,12 @@ dependencies {
|
||||
implementation(libs.zxing.android.embedded)
|
||||
implementation(libs.androidx.lifecycle.service)
|
||||
implementation(libs.ktor.client.okhttp)
|
||||
implementation(files("libs/open_sdk_3.5.19_r9483ffc7_lite.jar"))
|
||||
|
||||
implementation(libs.compose.runtime)
|
||||
implementation(libs.compose.foundation)
|
||||
implementation(libs.compose.material3)
|
||||
implementation(libs.compose.material.icons.extended)
|
||||
implementation(libs.compose.ui)
|
||||
implementation(libs.compose.ui.tooling.preview)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user