diff --git a/libs/apktool_2.3.4.jar b/libs/apktool_2.3.4.jar new file mode 100644 index 0000000..000e599 Binary files /dev/null and b/libs/apktool_2.3.4.jar differ diff --git a/src/com/qy/ui/ApkSignUi.java b/src/com/qy/ui/ApkSignUi.java index e07ab4b..40b52cb 100644 --- a/src/com/qy/ui/ApkSignUi.java +++ b/src/com/qy/ui/ApkSignUi.java @@ -3,8 +3,8 @@ package com.qy.ui; import javax.swing.*; import com.qy.utils.ApkSignTools; +import com.qy.utils.StringUtils; import com.qy.utils.Tools; -import org.apache.commons.lang3.StringUtils; import org.json.JSONObject; import java.awt.event.ActionListener; diff --git a/src/com/qy/ui/AppMain.java b/src/com/qy/ui/AppMain.java index d658f87..c796251 100755 --- a/src/com/qy/ui/AppMain.java +++ b/src/com/qy/ui/AppMain.java @@ -50,7 +50,7 @@ public class AppMain extends JFrame { private JMenuItem mntmBase; private static String cscPath = null; - private static String savePath=null; + private static String savePath = null; public static void main(String[] args) { /*args = new String[]{"-package=com.test.abc" @@ -69,7 +69,7 @@ public class AppMain extends JFrame { String model = "csj"; String jarPath = null; String jarType = null; - String config=null; + String config = null; int index = -1; @@ -101,11 +101,11 @@ public class AppMain extends JFrame { if (arg.startsWith("-index")) { index = Integer.parseInt(arg.replace("-index=", "").trim()); } - if(arg.startsWith("-save")){ - savePath= arg.replace("-save=", ""); + if (arg.startsWith("-save")) { + savePath = arg.replace("-save=", ""); } - if(arg.startsWith("-config")){ - config=arg.replace("-config=", ""); + if (arg.startsWith("-config")) { + config = arg.replace("-config=", ""); } if (arg.trim().equals("-h")) { outHelp(); @@ -114,7 +114,7 @@ public class AppMain extends JFrame { } if (model.equals("csj")) { if (packageName != null && version != null && apkPath != null && csjPath != null) { - new CsjTools(apkPath, csjPath, packageName, version,config, new SmaliApkToolsPath() { + new CsjTools(apkPath, csjPath, packageName, version, config, new SmaliApkToolsPath() { @Override public void smaliPath(String path) { if (cscPath != null) { @@ -140,7 +140,7 @@ public class AppMain extends JFrame { new File(path).renameTo(new File(savePath)); } }); - }else if(model.equals("sdk")){ + } else if (model.equals("sdk")) { new AutoPackageSDK(path -> new File(path).renameTo(new File(savePath)), version, packageName); } @@ -155,7 +155,7 @@ public class AppMain extends JFrame { "\n-csc csc save Path csc保存路径" + "\n-jar adsdk.jar path 需要被修改的sdk路径" + "\n-type sdk type sdk类型" + - "\n-index ad_config.cfg index 在ad_config.cfg配置中的array下标"+ + "\n-index ad_config.cfg index 在ad_config.cfg配置中的array下标" + "\n-save save jar path 保存jar的路径" ); } @@ -198,7 +198,8 @@ public class AppMain extends JFrame { BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); String tmp; while ((tmp = reader.readLine()) != null) { - phonePackageList.add(tmp.substring(8)); + if (!StringUtils.isEmpty(tmp)) + phonePackageList.add(tmp.substring(8)); } Collections.sort(phonePackageList); } catch (Exception e) { @@ -223,7 +224,7 @@ public class AppMain extends JFrame { // TODO: handle exception e.printStackTrace(); } - setTitle("\u8F6C\u6362\u5668v2.2"); + setTitle("\u8F6C\u6362\u5668v2.3"); // TODO Auto-generated constructor stub setSize(900, 456); getContentPane().setLayout(null); @@ -657,7 +658,7 @@ public class AppMain extends JFrame { autoOutApk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - new AutoOutAPKUi(); + new AutoOutAPKUi(); } }); menu.add(autoOutApk); diff --git a/src/com/qy/ui/AutoOutAPKUi.java b/src/com/qy/ui/AutoOutAPKUi.java index a1425ef..ac50f0c 100644 --- a/src/com/qy/ui/AutoOutAPKUi.java +++ b/src/com/qy/ui/AutoOutAPKUi.java @@ -4,8 +4,8 @@ import com.qy.Interfaces.DialogInterface; import com.qy.Interfaces.SmaliApkToolsPath; import com.qy.utils.ApkSignTools; import com.qy.utils.AutoOutAPKTools; +import com.qy.utils.StringUtils; import com.qy.utils.Tools; -import org.apache.commons.lang3.StringUtils; import org.json.JSONObject; import javax.swing.*; diff --git a/src/com/qy/ui/SmaliUi.java b/src/com/qy/ui/SmaliUi.java index 041e929..e3a2990 100755 --- a/src/com/qy/ui/SmaliUi.java +++ b/src/com/qy/ui/SmaliUi.java @@ -20,7 +20,7 @@ import com.qy.Interfaces.DialogInterface; import com.qy.Interfaces.SmaliApkToolsPath; import com.qy.utils.ApkSignTools; import com.qy.utils.SmaliUtils; -import org.apache.commons.lang3.StringUtils; +import com.qy.utils.StringUtils; import org.json.JSONObject; public class SmaliUi extends JFrame { @@ -95,7 +95,7 @@ public class SmaliUi extends JFrame { // TODO: handle exception e.printStackTrace(); } - setTitle("Smali\u53CD\u7F16\u8BD1\u5DE5\u5177v1.3"); + setTitle("Smali\u53CD\u7F16\u8BD1\u5DE5\u5177v1.4"); // TODO Auto-generated constructor stub setSize(900, 673); getContentPane().setLayout(null); diff --git a/src/com/qy/utils/ApkSignTools.java b/src/com/qy/utils/ApkSignTools.java index b5970a2..56b5f72 100644 --- a/src/com/qy/utils/ApkSignTools.java +++ b/src/com/qy/utils/ApkSignTools.java @@ -38,6 +38,7 @@ public class ApkSignTools { System.out.println(tmp); } reader.close(); + process.destroy(); return true; } catch (Exception e) { // TODO Auto-generated catch block diff --git a/src/com/qy/utils/AutoOutAPKTools.java b/src/com/qy/utils/AutoOutAPKTools.java index 44869bd..3933df3 100644 --- a/src/com/qy/utils/AutoOutAPKTools.java +++ b/src/com/qy/utils/AutoOutAPKTools.java @@ -34,6 +34,7 @@ public class AutoOutAPKTools { outLog("复制游戏文件夹"); String newAppPath=appPath+"_"+gameId+"_"+Tools.getRandomString(6); Tools.copy_dir(appPath,newAppPath); + String oldPath=appPath; outLog("游戏游戏文件夹复制完成"); appPath=newAppPath; outLog("修改Manifest"); @@ -41,10 +42,10 @@ public class AutoOutAPKTools { outLog("Manifest修改完成,开始生成assets"); outAssets(); outLog("生成完毕"); - new SmaliUtils().bale(appPath, appPath + File.separator + "game_.apk", new SmaliApkToolsPath() { + new SmaliUtils().bale(appPath, appPath + File.separator + new File(oldPath).getName()+gameId, new SmaliApkToolsPath() { @Override public void smaliPath(String path) { - inter.smaliPath(appPath + File.separator + "game_.apk"); + inter.smaliPath(appPath + File.separator + new File(oldPath).getName()+gameId); } }); } diff --git a/src/com/qy/utils/SmaliUtils.java b/src/com/qy/utils/SmaliUtils.java index b336c5e..31a9d2c 100755 --- a/src/com/qy/utils/SmaliUtils.java +++ b/src/com/qy/utils/SmaliUtils.java @@ -1,6 +1,8 @@ package com.qy.utils; import java.io.*; +import java.net.URL; +import java.net.URLClassLoader; import java.nio.ByteBuffer; import java.security.Permission; import java.util.ArrayList; @@ -8,15 +10,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Handler; -import java.util.logging.LogRecord; -import java.util.logging.Logger; -import brut.androlib.Androlib; -import brut.androlib.res.xml.ResXmlPatcher; import com.qy.Interfaces.SmaliApkToolsPath; -import brut.apktool.Main; import com.qy.ui.TextToDialog; import com.sun.javaws.exceptions.ExitException; @@ -27,6 +23,9 @@ public class SmaliUtils { // private String mainPath = "D:\\反编译\\APK\\rx.jar.out\\smali"; private Map clazzList; private List files = new ArrayList<>(); + private static ClassLoader apktool_234; + private static ClassLoader apktool_241; + public static void main(String[] args) { new SmaliUtils(); @@ -34,6 +33,17 @@ public class SmaliUtils { public SmaliUtils() { clazzList = new HashMap<>(); + try { + if(apktool_234==null){ + apktool_234=new URLClassLoader(new URL[]{new URL("file:libs/apktool_2.3.4.jar")}); + } + if(apktool_241==null){ + apktool_241=new URLClassLoader(new URL[]{new URL("file:libs/apktool_2.4.1.jar")}); + } + }catch (Exception e){ + e.printStackTrace(); + System.exit(0); + } } public void setPath(String uPath) { @@ -219,7 +229,9 @@ public class SmaliUtils { for (String arg : args) { System.out.print(arg + " "); } - Main.main(args); + System.out.println("\n"); + //Main.main(args); + apktool_241.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args}); File jarFile = new File(jarPath); String name; if (jarFile.getName().contains(".jar")) { @@ -246,7 +258,7 @@ public class SmaliUtils { public boolean run = false; public static StringBuffer error=new StringBuffer(); public void bale(String smaliPath, String path, SmaliApkToolsPath inter) { - String[] args = new String[]{"b", "-f", smaliPath, "-o", path}; + String[] args = new String[]{"-r","b", "-f", smaliPath, "-o", path}; for (String string : args) { System.out.print(string + " "); } @@ -269,15 +281,17 @@ public class SmaliUtils { } } System.setErr(old); + outputStream.close(); } catch (Exception e) { e.printStackTrace(); } } - }).start(); - System.setSecurityManager(new NoExitSecurityManager()); + }); + //System.setSecurityManager(new NoExitSecurityManager()); - Main.main(args); + //Main.main(args); + apktool_234.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args}); if (inter != null) { inter.smaliPath(path); } diff --git a/src/com/qy/utils/StringUtils.java b/src/com/qy/utils/StringUtils.java new file mode 100644 index 0000000..92fa357 --- /dev/null +++ b/src/com/qy/utils/StringUtils.java @@ -0,0 +1,10 @@ +package com.qy.utils; + +public class StringUtils { + public static boolean isEmpty(String str) { + if(str==null||str.trim().length()==0){ + return true; + } + return false; + } +} diff --git a/src/com/qy/utils/Tools.java b/src/com/qy/utils/Tools.java index 17af3ab..d44ce61 100755 --- a/src/com/qy/utils/Tools.java +++ b/src/com/qy/utils/Tools.java @@ -196,10 +196,10 @@ public class Tools { } } try { - FileWriter writer=new FileWriter(file); - writer.write(data); - writer.flush(); - writer.close(); + OutputStream outputStream=new FileOutputStream(file); + outputStream.write(new String(data.getBytes(),StandardCharsets.UTF_8).getBytes()); + outputStream.flush(); + outputStream.close(); } catch (Exception e) { e.printStackTrace(); }