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.
This commit is contained in:
Igor Eisberg 2019-02-15 15:09:28 +02:00 committed by Connor Tumbleson
parent 49e55f522f
commit 400a463286
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75

View File

@ -377,6 +377,25 @@ public class ApkDecoder {
private void putSdkInfo(MetaInfo meta) throws AndrolibException { private void putSdkInfo(MetaInfo meta) throws AndrolibException {
Map<String, String> info = getResTable().getSdkInfo(); Map<String, String> info = getResTable().getSdkInfo();
if (info.size() > 0) { 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; meta.sdkInfo = info;
} }
} }