DexRepair根据bin文件批量自动修复dex
https://github.com/luoyesiqiu/DexRepair
理论适用于 Fart 各个版本
适配mikrom1.0.1
增加的关键代码
public static void main(String[] args) {
FileChooser.choose();
System.exit(0);
}
public static void repair(String binPath,String dexPath){
if(new File(dexPath).exists() && new File(binPath).exists()) {
byte[] data = IoUtils.readFile(binPath);
List<CodeItem> items = DexUtils.convertToCodeItems(data);
DexUtils.patch(dexPath, items,true);
}
else{
System.err.println("Dex file or bin file not exists!");
}
}
选择需要修复的dex路径
public class FileChooser {
public static void choose() {
File folder = new File("bin,dex文件路径");
if (folder.isDirectory()) {
File[] files = folder.listFiles();
for (File file : files) {
String fileName = file.getName();
if(fileName.endsWith(".bin")){
String[] strings = fileName.split("_");
String dexName,binPath,dexPath;
switch (strings.length){
case 3:
dexName = strings[0]+"_dexfile.dex";
binPath = folder.getAbsolutePath()+"\\"+fileName;
dexPath = folder.getAbsolutePath()+"\\"+dexName;
System.out.println(binPath+"<=>"+dexPath);
DexRepair.repair(binPath, dexPath);
break;
case 4:
dexName = strings[0]+"_"+strings[1]+"_dexfile.dex";
binPath = folder.getAbsolutePath()+"\\"+fileName;
dexPath = folder.getAbsolutePath()+"\\"+dexName;
System.out.println(binPath+"<=>"+dexPath);
DexRepair.repair(binPath, dexPath);
break;
default:
break;
}
}
}
} else {
System.out.println("指定的路径不是一个文件夹");
}
}
}
代码待完善