穿山甲资源包生成 API化

This commit is contained in:
Yutousama 2020-06-03 00:00:10 +08:00
parent 85eec17ee6
commit 9c41ab000b
2 changed files with 38 additions and 31 deletions

View File

@ -1,3 +1,3 @@
Manifest-Version: 1.0 Manifest-Version: 1.0
Main-Class: com.qy.ui.AppMain Main-Class: com.qy.utils.CsjTools

View File

@ -1,7 +1,6 @@
package com.qy.utils; package com.qy.utils;
import com.qy.Interfaces.SmaliApkToolsPath; import com.qy.Interfaces.SmaliApkToolsPath;
import com.qy.ui.EditToDalog;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
@ -16,10 +15,29 @@ public class CsjTools {
private static String apk_Path = "D:\\IdeaProjects\\android_sdk_tools\\app-release"; private static String apk_Path = "D:\\IdeaProjects\\android_sdk_tools\\app-release";
private static String csj_Path = "D:\\IdeaProjects\\android_sdk_tools\\demo_2.8.0.2"; private static String csj_Path = "D:\\IdeaProjects\\android_sdk_tools\\demo_2.8.0.2";
private List<String> r_list; private List<String> r_list;
private String packageName = null;
public CsjTools() { public CsjTools() {
} }
public CsjTools(String apkFile, String csjFile, String packageName, String version, SmaliApkToolsPath toolsPath) {
setUserPackageName(false);
this.packageName = packageName;
build(csjFile, apkFile, new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
System.out.println(path);
if(path.startsWith("已出包")) {
out(path.replace("已出包", ""),
new File("csj").getAbsolutePath() + File.separator + "csc",
Integer.parseInt(version));
toolsPath.smaliPath(new File("csj").getAbsolutePath() + File.separator + "csc");
}
}
});
}
public String loadXml(String path) { public String loadXml(String path) {
File file = new File(path); File file = new File(path);
String xml = null; String xml = null;
@ -66,19 +84,22 @@ public class CsjTools {
} }
return null; return null;
} }
private boolean isAppPackageName =false;
public void setUserPackageName(boolean isAppPackageName){ private boolean isAppPackageName = false;
this.isAppPackageName=isAppPackageName;
public void setUserPackageName(boolean isAppPackageName) {
this.isAppPackageName = isAppPackageName;
} }
private String getPackageName() { private String getPackageName() {
try { try {
if(isAppPackageName) { if (isAppPackageName) {
File apkManifest = new File(apk_Path + File.separator + "AndroidManifest.xml"); File apkManifest = new File(apk_Path + File.separator + "AndroidManifest.xml");
BufferedReader reader = new BufferedReader(new FileReader(apkManifest)); BufferedReader reader = new BufferedReader(new FileReader(apkManifest));
String tmp = reader.readLine(); String tmp = reader.readLine();
reader.close(); reader.close();
return getXMLValue("package", tmp); return getXMLValue("package", tmp);
}else{ } else {
return "com.prujwk.jdyphn"; return "com.prujwk.jdyphn";
} }
} catch (Exception e) { } catch (Exception e) {
@ -325,30 +346,16 @@ public class CsjTools {
//还有最后一个问题穿山甲的Activity没改 //还有最后一个问题穿山甲的Activity没改
public static void main(String[] args) { public static void main(String[] args) {
CsjTools tools = new CsjTools(); new CsjTools("C:\\Users\\58381\\Documents\\WeChat Files\\z583819556\\FileStorage\\File\\2020-04\\CasualGame-release.apk"
tools.build("D:\\IdeaProjects\\android_sdk_tools\\demo_2.8.0.2.apk", , "E:\\idea\\android_sdk_tools\\input\\csjDemo\\demo_2.9.0.0.apk"
"D:\\IdeaProjects\\android_sdk_tools\\app-release.apk", , "com.abc.test"
new SmaliApkToolsPath() { , "5700"
@Override , new SmaliApkToolsPath() {
public void smaliPath(String log) { @Override
System.out.println(log); public void smaliPath(String path) {
if (log.startsWith("已出包")) { System.out.println("打包完成:"+path);
System.out.println("打包完成"); }
new EditToDalog("成功", "打包完成,请输入版本号", "5600", new SmaliApkToolsPath() { });
@Override
public void smaliPath(String path) {
System.out.println(">>" + path);
tools.out(log.replace("已出包", ""),
new File("csj").getAbsolutePath() + File.separator + "csc",
Integer.parseInt(path));
}
});
}
}
});
// tools.outManifest();
// tools.start();
} }
} }