From 6076ab157fca8db6f186fc01b3bc9e6c35e4dd49 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sat, 21 Nov 2026 02:06:10 +0000 Subject: [PATCH 1/3] Update dependency com.android.tools.apkparser:binary-resources to v32 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a521298a..9ba002df 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,7 @@ protobufJava = "3.19.2" guava = "31.0.1-jre" dalvikdx = "16.0.1" -apkparser = "31.13.2" +apkparser = "32.5.2" apksign = "9.5.2" clikt = "5.2.1" junit = "5.14.4" From b95537c46e7a4cd11ae5888e0cf2c94b9fe61761 Mon Sep 17 00:00:00 2001 From: Mateusz Kwiecinski Date: Sat, 21 Nov 2026 09:48:32 +0100 Subject: [PATCH 2/3] Migrate to binary-resources 32 API binary-resources 32 renamed BinaryResourceFile/BinaryResourceValue to ResourceFile/ResourceValue (same constructors, type()/data() and Type enum). It is also compiled to Java 17 bytecode, so the minimum supported runtime is raised from 11 to 17. Adds golden tests for the decoded binary AndroidManifest of the fixture APKs, generated with binary-resources 31.13.2. Co-Authored-By: Claude Opus 5.5 --- diffuse/build.gradle | 2 +- .../jakewharton/diffuse/ApkManifestTest.kt | 40 + .../resources/github-browser/manifest-a.txt | 68 ++ .../resources/github-browser/manifest-b.txt | 68 ++ .../otwarty-wykop-mobilny/manifest.txt | 732 ++++++++++++++++++ .../test/resources/stripe/manifest-master.txt | 238 ++++++ .../src/test/resources/stripe/manifest-pr.txt | 238 ++++++ .../diffuse/format/AndroidManifest.kt | 26 +- .../com/jakewharton/diffuse/format/Apk.kt | 2 +- .../com/jakewharton/diffuse/format/Arsc.kt | 4 +- .../com/jakewharton/diffuse/format/util.kt | 4 +- gradle/libs.versions.toml | 2 +- 12 files changed, 1404 insertions(+), 20 deletions(-) create mode 100644 diffuse/src/test/kotlin/com/jakewharton/diffuse/ApkManifestTest.kt create mode 100644 diffuse/src/test/resources/github-browser/manifest-a.txt create mode 100644 diffuse/src/test/resources/github-browser/manifest-b.txt create mode 100644 diffuse/src/test/resources/otwarty-wykop-mobilny/manifest.txt create mode 100644 diffuse/src/test/resources/stripe/manifest-master.txt create mode 100644 diffuse/src/test/resources/stripe/manifest-pr.txt diff --git a/diffuse/build.gradle b/diffuse/build.gradle index bba835d8..91d085b5 100644 --- a/diffuse/build.gradle +++ b/diffuse/build.gradle @@ -102,7 +102,7 @@ def binaryJar = tasks.register("binaryDiffuseJar") { task -> } } -[11, 17].forEach { majorVersion -> +[17].forEach { majorVersion -> def jdkTest = tasks.register("testJdk$majorVersion", Test) { javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(majorVersion) diff --git a/diffuse/src/test/kotlin/com/jakewharton/diffuse/ApkManifestTest.kt b/diffuse/src/test/kotlin/com/jakewharton/diffuse/ApkManifestTest.kt new file mode 100644 index 00000000..71cfc870 --- /dev/null +++ b/diffuse/src/test/kotlin/com/jakewharton/diffuse/ApkManifestTest.kt @@ -0,0 +1,40 @@ +package com.jakewharton.diffuse + +import com.jakewharton.diffuse.format.Apk.Companion.toApk +import com.jakewharton.diffuse.io.Input.Companion.asInput +import java.io.File +import kotlin.io.path.Path +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ApkManifestTest { + + @Test + fun `binary manifest of stripe master`() = assertManifest("stripe/paymentsheet-example-release-master.apk", "stripe/manifest-master.txt") + + @Test + fun `binary manifest of stripe pr`() = assertManifest("stripe/paymentsheet-example-release-pr.apk", "stripe/manifest-pr.txt") + + @Test + fun `binary manifest of signed artifact`() = assertManifest("otwarty-wykop-mobilny/app-release.apk", "otwarty-wykop-mobilny/manifest.txt") + + @Test + fun `binary manifest of obfuscated artifact A`() = assertManifest("github-browser/apkA.apk", "github-browser/manifest-a.txt") + + @Test + fun `binary manifest of obfuscated artifact B`() = assertManifest("github-browser/apkB.apk", "github-browser/manifest-b.txt") + + private fun assertManifest(apk: String, expected: String) { + val manifest = Path(loadResource(apk)).asInput().toApk().manifest + + val actual = buildString { + appendLine("package: ${manifest.packageName}") + appendLine("versionName: ${manifest.versionName}") + appendLine("versionCode: ${manifest.versionCode}") + appendLine() + append(manifest.xml) + } + + assertThat(actual).isEqualTo(File(loadResource(expected)).readText()) + } +} diff --git a/diffuse/src/test/resources/github-browser/manifest-a.txt b/diffuse/src/test/resources/github-browser/manifest-a.txt new file mode 100644 index 00000000..aaabb89a --- /dev/null +++ b/diffuse/src/test/resources/github-browser/manifest-a.txt @@ -0,0 +1,68 @@ +package: pl.mateuszkwiecinski.browser +versionName: 0.2.0 +versionCode: 2000 + + + + + + + + + + + + + + + + + + + diff --git a/diffuse/src/test/resources/github-browser/manifest-b.txt b/diffuse/src/test/resources/github-browser/manifest-b.txt new file mode 100644 index 00000000..aaabb89a --- /dev/null +++ b/diffuse/src/test/resources/github-browser/manifest-b.txt @@ -0,0 +1,68 @@ +package: pl.mateuszkwiecinski.browser +versionName: 0.2.0 +versionCode: 2000 + + + + + + + + + + + + + + + + + + + diff --git a/diffuse/src/test/resources/otwarty-wykop-mobilny/manifest.txt b/diffuse/src/test/resources/otwarty-wykop-mobilny/manifest.txt new file mode 100644 index 00000000..ea36b8e4 --- /dev/null +++ b/diffuse/src/test/resources/otwarty-wykop-mobilny/manifest.txt @@ -0,0 +1,732 @@ +package: io.github.wykopmobilny +versionName: 1.3.0 +versionCode: 1003000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/diffuse/src/test/resources/stripe/manifest-master.txt b/diffuse/src/test/resources/stripe/manifest-master.txt new file mode 100644 index 00000000..737406bf --- /dev/null +++ b/diffuse/src/test/resources/stripe/manifest-master.txt @@ -0,0 +1,238 @@ +package: com.stripe.android.paymentsheet.example +versionName: 1.0 +versionCode: 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/diffuse/src/test/resources/stripe/manifest-pr.txt b/diffuse/src/test/resources/stripe/manifest-pr.txt new file mode 100644 index 00000000..737406bf --- /dev/null +++ b/diffuse/src/test/resources/stripe/manifest-pr.txt @@ -0,0 +1,238 @@ +package: com.stripe.android.paymentsheet.example +versionName: 1.0 +versionCode: 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/formats/src/main/kotlin/com/jakewharton/diffuse/format/AndroidManifest.kt b/formats/src/main/kotlin/com/jakewharton/diffuse/format/AndroidManifest.kt index 733f134e..e481b6ae 100644 --- a/formats/src/main/kotlin/com/jakewharton/diffuse/format/AndroidManifest.kt +++ b/formats/src/main/kotlin/com/jakewharton/diffuse/format/AndroidManifest.kt @@ -3,17 +3,17 @@ package com.jakewharton.diffuse.format import com.android.aapt.Resources.XmlNode import com.android.tools.build.bundletool.model.utils.xmlproto.XmlProtoNode import com.android.tools.build.bundletool.xml.XmlProtoToXmlConverter -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceFile -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceValue.Type.INT_BOOLEAN -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceValue.Type.INT_COLOR_ARGB4 -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceValue.Type.INT_COLOR_ARGB8 -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceValue.Type.INT_COLOR_RGB4 -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceValue.Type.INT_COLOR_RGB8 -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceValue.Type.INT_DEC -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceValue.Type.INT_HEX -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceValue.Type.NULL -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceValue.Type.REFERENCE -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceValue.Type.STRING +import com.google.devrel.gmscore.tools.apk.arsc.ResourceFile +import com.google.devrel.gmscore.tools.apk.arsc.ResourceValue.Type.INT_BOOLEAN +import com.google.devrel.gmscore.tools.apk.arsc.ResourceValue.Type.INT_COLOR_ARGB4 +import com.google.devrel.gmscore.tools.apk.arsc.ResourceValue.Type.INT_COLOR_ARGB8 +import com.google.devrel.gmscore.tools.apk.arsc.ResourceValue.Type.INT_COLOR_RGB4 +import com.google.devrel.gmscore.tools.apk.arsc.ResourceValue.Type.INT_COLOR_RGB8 +import com.google.devrel.gmscore.tools.apk.arsc.ResourceValue.Type.INT_DEC +import com.google.devrel.gmscore.tools.apk.arsc.ResourceValue.Type.INT_HEX +import com.google.devrel.gmscore.tools.apk.arsc.ResourceValue.Type.NULL +import com.google.devrel.gmscore.tools.apk.arsc.ResourceValue.Type.REFERENCE +import com.google.devrel.gmscore.tools.apk.arsc.ResourceValue.Type.STRING import com.google.devrel.gmscore.tools.apk.arsc.XmlChunk import com.google.devrel.gmscore.tools.apk.arsc.XmlEndElementChunk import com.google.devrel.gmscore.tools.apk.arsc.XmlNamespaceStartChunk @@ -45,7 +45,7 @@ class AndroidManifest private constructor( isNamespaceAware = true } - internal fun BinaryResourceFile.toManifest(arsc: Arsc? = null): AndroidManifest = toDocument(arsc).toManifest() + internal fun ResourceFile.toManifest(arsc: Arsc? = null): AndroidManifest = toDocument(arsc).toManifest() @JvmStatic @JvmName("parse") @@ -59,7 +59,7 @@ class AndroidManifest private constructor( .apply { normalizeWhitespace() } .toManifest() - private fun BinaryResourceFile.toDocument(arsc: Arsc?): Document { + private fun ResourceFile.toDocument(arsc: Arsc?): Document { val rootChunk = requireNotNull(chunks.singleOrNull() as XmlChunk?) { "Unable to parse manifest from binary XML" } diff --git a/formats/src/main/kotlin/com/jakewharton/diffuse/format/Apk.kt b/formats/src/main/kotlin/com/jakewharton/diffuse/format/Apk.kt index 8eb08501..d85b9683 100644 --- a/formats/src/main/kotlin/com/jakewharton/diffuse/format/Apk.kt +++ b/formats/src/main/kotlin/com/jakewharton/diffuse/format/Apk.kt @@ -26,7 +26,7 @@ class Apk private constructor( toZip().use { zip -> val files = zip.toArchiveFiles { it.toApkFileType() } val arsc = zip[Arsc.NAME].asInput().toArsc() - val manifest = zip[AndroidManifest.NAME].asInput().toBinaryResourceFile().toManifest(arsc) + val manifest = zip[AndroidManifest.NAME].asInput().toResourceFile().toManifest(arsc) val dexes = zip.entries .filter { it.path.matches(classesDexRegex) } .map { it.asInput().toDex() } diff --git a/formats/src/main/kotlin/com/jakewharton/diffuse/format/Arsc.kt b/formats/src/main/kotlin/com/jakewharton/diffuse/format/Arsc.kt index f82b78ab..4fea835c 100644 --- a/formats/src/main/kotlin/com/jakewharton/diffuse/format/Arsc.kt +++ b/formats/src/main/kotlin/com/jakewharton/diffuse/format/Arsc.kt @@ -26,7 +26,7 @@ class Arsc private constructor( @JvmStatic @JvmName("create") fun Input.toArsc(): Arsc { - val chunk = toBinaryResourceFile().chunks.single() + val chunk = toResourceFile().chunks.single() check(chunk is ResourceTableChunk) { "Root arsc chunk is not a resource table " } val configs = mutableListOf() @@ -43,7 +43,7 @@ class Arsc private constructor( val typeId = typeChunk.id for ((entryId, entry) in typeChunk.entries) { - // See BinaryResourceIdentifier for the source of this algorithm. + // See ResourceIdentifier for the source of this algorithm. val id = ((packageId and 0xFF) shl 24) or ((typeId and 0xFF) shl 16) or ((entryId and 0xFFFF)) diff --git a/formats/src/main/kotlin/com/jakewharton/diffuse/format/util.kt b/formats/src/main/kotlin/com/jakewharton/diffuse/format/util.kt index 17dc33c3..ca622f77 100644 --- a/formats/src/main/kotlin/com/jakewharton/diffuse/format/util.kt +++ b/formats/src/main/kotlin/com/jakewharton/diffuse/format/util.kt @@ -1,6 +1,6 @@ package com.jakewharton.diffuse.format -import com.google.devrel.gmscore.tools.apk.arsc.BinaryResourceFile +import com.google.devrel.gmscore.tools.apk.arsc.ResourceFile import com.jakewharton.diffuse.io.Input -internal fun Input.toBinaryResourceFile() = BinaryResourceFile(toByteArray()) +internal fun Input.toResourceFile() = ResourceFile(toByteArray()) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9ba002df..358972e3 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] java-compilation = "27" -java-target = "11" +java-target = "17" bundletool = "1.18.3" # Keep this values in sync with bundletool"s dependencies. aapt2Proto = "7.3.0-alpha07-8248216" From 4f2cf8a78b8c868c3b4a1884c389adb65cbf9338 Mon Sep 17 00:00:00 2001 From: Mateusz Kwiecinski Date: Sat, 21 Nov 2026 09:56:48 +0100 Subject: [PATCH 3/3] Test on all supported LTS JDKs (17, 21, 25) Co-Authored-By: Claude Opus 5.5 --- diffuse/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diffuse/build.gradle b/diffuse/build.gradle index 91d085b5..5aee9532 100644 --- a/diffuse/build.gradle +++ b/diffuse/build.gradle @@ -102,7 +102,7 @@ def binaryJar = tasks.register("binaryDiffuseJar") { task -> } } -[17].forEach { majorVersion -> +[17, 21, 25].forEach { majorVersion -> def jdkTest = tasks.register("testJdk$majorVersion", Test) { javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(majorVersion)