mirror of
https://github.com/revanced/Apktool.git
synced 2024-11-11 15:09:24 +01:00
Merge branch 'smali-api-level' of https://github.com/benjamin-promon/Apktool into benjamin-promon-smali-api-level
This commit is contained in:
commit
c1b4e0d321
@ -51,6 +51,7 @@ public class Androlib {
|
||||
private final AndrolibResources mAndRes = new AndrolibResources();
|
||||
protected final ResUnknownFiles mResUnknownFiles = new ResUnknownFiles();
|
||||
public ApkOptions apkOptions;
|
||||
private int mMinSdkVersion = 0;
|
||||
|
||||
public Androlib(ApkOptions apkOptions) {
|
||||
this.apkOptions = apkOptions;
|
||||
@ -278,6 +279,10 @@ public class Androlib {
|
||||
mAndRes.setVersionInfo(meta.versionInfo);
|
||||
mAndRes.setSharedLibrary(meta.sharedLibrary);
|
||||
|
||||
if (meta.sdkInfo != null && meta.sdkInfo.get("minSdkVersion") != null) {
|
||||
mMinSdkVersion = Integer.parseInt(meta.sdkInfo.get("minSdkVersion"));
|
||||
}
|
||||
|
||||
if (outFile == null) {
|
||||
String outFileName = meta.apkFileName;
|
||||
outFile = new File(appDir, "dist" + File.separator + (outFileName == null ? "out.apk" : outFileName));
|
||||
@ -397,7 +402,7 @@ public class Androlib {
|
||||
if (apkOptions.forceBuildAll || isModified(smaliDir, dex)) {
|
||||
LOGGER.info("Smaling " + folder + " folder into " + filename +"...");
|
||||
dex.delete();
|
||||
SmaliBuilder.build(smaliDir, dex);
|
||||
SmaliBuilder.build(smaliDir, dex, mMinSdkVersion);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.antlr.runtime.RecognitionException;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jf.dexlib2.Opcodes;
|
||||
import org.jf.dexlib2.writer.builder.DexBuilder;
|
||||
import org.jf.dexlib2.writer.io.FileDataStore;
|
||||
|
||||
@ -33,19 +34,28 @@ import org.jf.dexlib2.writer.io.FileDataStore;
|
||||
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
|
||||
*/
|
||||
public class SmaliBuilder {
|
||||
|
||||
public static void build(ExtFile smaliDir, File dexFile) throws AndrolibException {
|
||||
new SmaliBuilder(smaliDir, dexFile).build();
|
||||
public static void build(ExtFile smaliDir, File dexFile, int apiLevel) throws AndrolibException {
|
||||
new SmaliBuilder(smaliDir, dexFile, apiLevel).build();
|
||||
}
|
||||
|
||||
private SmaliBuilder(ExtFile smaliDir, File dexFile) {
|
||||
public static void build(ExtFile smaliDir, File dexFile) throws AndrolibException {
|
||||
new SmaliBuilder(smaliDir, dexFile, 0).build();
|
||||
}
|
||||
|
||||
private SmaliBuilder(ExtFile smaliDir, File dexFile, int apiLevel) {
|
||||
mSmaliDir = smaliDir;
|
||||
mDexFile = dexFile;
|
||||
mApiLevel = apiLevel;
|
||||
}
|
||||
|
||||
private void build() throws AndrolibException {
|
||||
try {
|
||||
DexBuilder dexBuilder = DexBuilder.makeDexBuilder();
|
||||
DexBuilder dexBuilder;
|
||||
if (mApiLevel > 0) {
|
||||
dexBuilder = DexBuilder.makeDexBuilder(Opcodes.forApi(mApiLevel));
|
||||
} else {
|
||||
dexBuilder = DexBuilder.makeDexBuilder();
|
||||
}
|
||||
|
||||
for (String fileName : mSmaliDir.getDirectory().getFiles(true)) {
|
||||
buildFile(fileName, dexBuilder);
|
||||
@ -77,6 +87,7 @@ public class SmaliBuilder {
|
||||
|
||||
private final ExtFile mSmaliDir;
|
||||
private final File mDexFile;
|
||||
private int mApiLevel = 0;
|
||||
|
||||
private final static Logger LOGGER = Logger.getLogger(SmaliBuilder.class.getName());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user