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