fix: use versionCode if versionName is unavailable

This commit is contained in:
oSumAtrIX 2023-06-18 16:39:49 +02:00
parent f3c9e28a62
commit 6e1b6479b6
No known key found for this signature in database
GPG key ID: A9B3094ACDB604B4

View file

@ -249,6 +249,7 @@ class Patcher(private val options: PatcherOptions) {
axmlParser, AndrolibResources().resXmlSerializer
).decodeManifest(
extInputFile.directory.getFileInput("AndroidManifest.xml"),
// Older Android versions do not support OutputStream.nullOutputStream()
object : OutputStream() {
override fun write(b: Int) {
// do nothing
@ -261,7 +262,7 @@ class Patcher(private val options: PatcherOptions) {
// read of the resourceTable which is created by reading the manifest file
context.packageMetadata.let { metadata ->
metadata.packageName = resourceTable.currentResPackage.name
metadata.packageVersion = resourceTable.versionInfo.versionName
metadata.packageVersion = resourceTable.versionInfo.versionName ?: resourceTable.versionInfo.versionCode
metadata.metaInfo.versionInfo = resourceTable.versionInfo
metadata.metaInfo.sdkInfo = resourceTable.sdkInfo
}