SmaliUtils打包工具还是需要监听异常的。。。
This commit is contained in:
parent
ca4518724a
commit
d0404453ca
@ -5,16 +5,16 @@ import com.qy.ui.ApkSignUi;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 在广州梦娱网络科技有限公司工作时所用的打包工具
|
||||
*/
|
||||
public class AutoOutAPKTools {
|
||||
private String gameId;
|
||||
private Map<String,String> channel;
|
||||
private Map<String, String> channel;
|
||||
private JSONObject manifestMap;
|
||||
private String appPath;
|
||||
private SmaliApkToolsPath inter;
|
||||
@ -23,86 +23,93 @@ public class AutoOutAPKTools {
|
||||
this.gameId = gameId;
|
||||
this.channel = channel;
|
||||
}
|
||||
public void setAppPath(String path){
|
||||
this.appPath=path;
|
||||
|
||||
public void setAppPath(String path) {
|
||||
this.appPath = path;
|
||||
}
|
||||
public void setManifestMap(JSONObject map){
|
||||
this.manifestMap=map;
|
||||
|
||||
public void setManifestMap(JSONObject map) {
|
||||
this.manifestMap = map;
|
||||
}
|
||||
public void start(SmaliApkToolsPath inter){
|
||||
this.inter=inter;
|
||||
|
||||
public void start(SmaliApkToolsPath inter) {
|
||||
this.inter = inter;
|
||||
outLog("复制游戏文件夹");
|
||||
String newAppPath=appPath+"_"+gameId+"_"+Tools.getRandomString(6);
|
||||
Tools.copy_dir(appPath,newAppPath);
|
||||
String oldPath=appPath;
|
||||
String newAppPath = appPath + "_" + gameId + "_" + Tools.getRandomString(6);
|
||||
Tools.copy_dir(appPath, newAppPath);
|
||||
String oldPath = appPath;
|
||||
outLog("游戏游戏文件夹复制完成");
|
||||
appPath=newAppPath;
|
||||
appPath = newAppPath;
|
||||
outLog("修改Manifest");
|
||||
alterManifest(new File(appPath+File.separator+"AndroidManifest.xml"));
|
||||
alterManifest(new File(appPath + File.separator + "AndroidManifest.xml"));
|
||||
outLog("Manifest修改完成,开始生成assets");
|
||||
outAssets();
|
||||
outLog("生成完毕");
|
||||
new SmaliUtils().bale(appPath, appPath + File.separator + new File(oldPath).getName()+gameId, 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 + new File(oldPath).getName()+gameId);
|
||||
inter.smaliPath(appPath + File.separator + new File(oldPath).getName() + gameId);
|
||||
}
|
||||
});
|
||||
}
|
||||
public void clear(){
|
||||
|
||||
public void clear() {
|
||||
Tools.deleteFiles(appPath);
|
||||
}
|
||||
private void alterManifest(File manifest){
|
||||
|
||||
private void alterManifest(File manifest) {
|
||||
String tmp;
|
||||
StringBuilder str = new StringBuilder();
|
||||
try {
|
||||
List<String> keys=new ArrayList<>(manifestMap.keySet());
|
||||
List<String> keys = new ArrayList<>(manifestMap.keySet());
|
||||
|
||||
BufferedReader reader = new BufferedReader( new InputStreamReader(new FileInputStream(manifest), StandardCharsets.UTF_8));
|
||||
while ((tmp = reader.readLine()) != null) {
|
||||
for (String key : keys) {
|
||||
if(tmp.contains(key)){
|
||||
JSONObject json=manifestMap.getJSONObject(key);
|
||||
tmp=tmp.replace(json.getString("key"),json.getString("value"));
|
||||
if (tmp.contains(key)) {
|
||||
JSONObject json = manifestMap.getJSONObject(key);
|
||||
tmp = tmp.replace(json.getString("key"), json.getString("value"));
|
||||
}
|
||||
}
|
||||
str.append(tmp).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
Tools.saveConfig(manifest,str.toString());
|
||||
Tools.saveConfig(manifest, str.toString());
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
System.out.println(str);
|
||||
}
|
||||
}
|
||||
private void outAssets(){
|
||||
StringBuilder builder=new StringBuilder();
|
||||
|
||||
private void outAssets() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GAME_ID=").append(gameId).append("\n");
|
||||
for (String key : channel.keySet()) {
|
||||
builder.append(key).append("=").append(channel.get(key)).append("\n");
|
||||
}
|
||||
Tools.saveConfig(new File(appPath+File.separator+"assets"+File.separator+"kusdkconf.ini"),
|
||||
Tools.saveConfig(new File(appPath + File.separator + "assets" + File.separator + "kusdkconf.ini"),
|
||||
builder.toString());
|
||||
}
|
||||
private void outLog(String log){
|
||||
|
||||
private void outLog(String log) {
|
||||
System.out.println(log);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
JSONObject json=new JSONObject();
|
||||
JSONObject pa=new JSONObject();
|
||||
JSONObject ji=new JSONObject();
|
||||
pa.put("key","${packagename}");
|
||||
pa.put("value","com.abc.def");
|
||||
ji.put("key","${JPUSH_KEY}");
|
||||
ji.put("value","aaabbccd");
|
||||
json.put("package=",pa);
|
||||
json.put("JPUSH_APPKEY",ji);
|
||||
JSONObject json = new JSONObject();
|
||||
JSONObject pa = new JSONObject();
|
||||
JSONObject ji = new JSONObject();
|
||||
pa.put("key", "${packagename}");
|
||||
pa.put("value", "com.abc.def");
|
||||
ji.put("key", "${JPUSH_KEY}");
|
||||
ji.put("value", "aaabbccd");
|
||||
json.put("package=", pa);
|
||||
json.put("JPUSH_APPKEY", ji);
|
||||
|
||||
Map<String,String> channel=new HashMap<>();
|
||||
channel.put("TOUTIAO_APP_ID","112345");
|
||||
AutoOutAPKTools tools=new AutoOutAPKTools(
|
||||
Map<String, String> channel = new HashMap<>();
|
||||
channel.put("TOUTIAO_APP_ID", "112345");
|
||||
AutoOutAPKTools tools = new AutoOutAPKTools(
|
||||
"123456",
|
||||
channel);
|
||||
tools.setAppPath("C:\\Users\\admin\\Documents\\游戏母包\\仙侠神域\\xianxiashenyu_29321_wozaijianghukey_xxsy_1627");
|
||||
@ -110,7 +117,7 @@ public class AutoOutAPKTools {
|
||||
tools.start(new SmaliApkToolsPath() {
|
||||
@Override
|
||||
public void smaliPath(String path) {
|
||||
System.out.println("ok:"+path);
|
||||
System.out.println("ok:" + path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -287,8 +287,8 @@ public class SmaliUtils {
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
//System.setSecurityManager(new NoExitSecurityManager());
|
||||
}).start();
|
||||
System.setSecurityManager(new NoExitSecurityManager());
|
||||
|
||||
//Main.main(args);
|
||||
apktool_234.loadClass("brut.apktool.Main").getMethod("main",String[].class).invoke(null,new Object[]{args});
|
||||
|
Loading…
Reference in New Issue
Block a user