Skip to content

Commit c91562a

Browse files
committed
fix(abi):fixed versionname
1 parent 5ee2f2f commit c91562a

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

android/app/build.gradle

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,23 @@ android {
116116
}
117117
}
118118

119-
import com.android.build.OutputFile
120-
import com.android.build.gradle.internal.api.BaseVariantOutputImpl
121-
122-
android.applicationVariants.all { variant ->
123-
variant.outputs.each { output ->
124-
def abi = output.getFilter(OutputFile.ABI) // 对 universal APK 会返回 null
125-
def versionName = variant.versionName
126-
def fileName = "OpenListF-v${versionName}${abi ? "_${abi}" : ""}.apk"
127-
128-
def outputImpl = output as BaseVariantOutputImpl
129-
outputImpl.outputFileName = fileName
119+
androidComponents {
120+
onVariants(selector().all()) { variant ->
121+
variant.outputs.forEach { output ->
122+
def abi = null
123+
for (filter in output.filters) {
124+
if (filter.filterType.name() == "ABI") {
125+
abi = filter.identifier
126+
break
127+
}
128+
}
129+
def suffix = abi != null ? "_${abi}" : ""
130+
131+
// 这里用 output 的 versionName,兼容性更好
132+
def versionName = output.versionName.orNull ?: "1.0.0"
133+
134+
output.outputFileName.set("OpenListF-v${versionName}${suffix}.apk")
135+
}
130136
}
131137
}
132138

0 commit comments

Comments
 (0)