From 6e1b6479b677657c226693e9cc6b63f4ef2ee060 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sun, 18 Jun 2023 16:39:49 +0200 Subject: [PATCH] fix: use `versionCode` if `versionName` is unavailable --- src/main/kotlin/app/revanced/patcher/Patcher.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/app/revanced/patcher/Patcher.kt b/src/main/kotlin/app/revanced/patcher/Patcher.kt index 2448592..388190c 100644 --- a/src/main/kotlin/app/revanced/patcher/Patcher.kt +++ b/src/main/kotlin/app/revanced/patcher/Patcher.kt @@ -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 }