Skip to content

Commit 47ab8da

Browse files
committed
fix(agp):Update Gradle build report with additional deprecation warnings
1 parent a0bb892 commit 47ab8da

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

android/app/build.gradle

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,16 +117,29 @@ android {
117117
}
118118

119119
androidComponents {
120-
onVariants { variant ->
121-
variant.outputs.forEach { output ->
122-
def abi = output.filters.find { it.filterType.name() == "ABI" }?.identifier
123-
def versionName = variant.versionName.get()
124-
def fileName = "OpenListF-v${versionName}"
125-
if (abi != null && !abi.isEmpty()) {
126-
fileName += "_${abi}"
120+
onVariants(selector().all()) { variant ->
121+
def variantNameCap = variant.name.capitalize()
122+
def copyTask = tasks.register("copy${variantNameCap}Apk", Copy) {
123+
from(variant.artifacts.get(com.android.build.api.artifact.SingleArtifact.APK))
124+
into(layout.buildDirectory.dir("renamed-apks"))
125+
rename { fileName ->
126+
def abi = "" // 如果你需要,可以在这里动态加入 ABI
127+
def versionName = variant.versionName.get()
128+
return "OpenListF-v${versionName}${abi ? "_$abi" : ''}.apk"
129+
}
130+
}
131+
132+
// 使用 afterEvaluate 来确保任务存在后再配置依赖关系
133+
project.afterEvaluate {
134+
def assembleTaskName = "assemble${variantNameCap}"
135+
if (tasks.findByName(assembleTaskName)) {
136+
tasks.named(assembleTaskName).configure {
137+
finalizedBy copyTask
138+
}
139+
copyTask.configure {
140+
dependsOn assembleTaskName
141+
}
127142
}
128-
fileName += ".apk"
129-
output.outputFileName.set(fileName)
130143
}
131144
}
132145
}

0 commit comments

Comments
 (0)