From 400a463286b756fbafb40f5b247b4f87b92ae58a Mon Sep 17 00:00:00 2001 From: Igor Eisberg Date: Fri, 15 Feb 2019 15:09:28 +0200 Subject: [PATCH] Fix APKs with SDK versions being reference values This non-standard behavior is rare, but quite annoying. The solution is simple - replacing the reference value with the actual value from integers.xml, just like Apktool already does for versionName. --- .../main/java/brut/androlib/ApkDecoder.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java index 4bf5b001..aad70b9d 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/ApkDecoder.java @@ -377,6 +377,25 @@ public class ApkDecoder { private void putSdkInfo(MetaInfo meta) throws AndrolibException { Map info = getResTable().getSdkInfo(); if (info.size() > 0) { + String refValue; + if (info.get("minSdkVersion") != null) { + refValue = ResXmlPatcher.pullValueFromIntegers(mOutDir, info.get("minSdkVersion")); + if (refValue != null) { + info.put("minSdkVersion", refValue); + } + } + if (info.get("targetSdkVersion") != null) { + refValue = ResXmlPatcher.pullValueFromIntegers(mOutDir, info.get("targetSdkVersion")); + if (refValue != null) { + info.put("targetSdkVersion", refValue); + } + } + if (info.get("maxSdkVersion") != null) { + refValue = ResXmlPatcher.pullValueFromIntegers(mOutDir, info.get("maxSdkVersion")); + if (refValue != null) { + info.put("maxSdkVersion", refValue); + } + } meta.sdkInfo = info; } }