From 9c41ab000b152892d8a4f631eb8dab9dc83a1988 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Wed, 3 Jun 2020 00:00:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A9=BF=E5=B1=B1=E7=94=B2=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E5=8C=85=E7=94=9F=E6=88=90=20API=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/META-INF/MANIFEST.MF | 2 +- src/com/qy/utils/CsjTools.java | 67 +++++++++++++++++++--------------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF index 807b30e..e0e7482 100644 --- a/src/META-INF/MANIFEST.MF +++ b/src/META-INF/MANIFEST.MF @@ -1,3 +1,3 @@ Manifest-Version: 1.0 -Main-Class: com.qy.ui.AppMain +Main-Class: com.qy.utils.CsjTools diff --git a/src/com/qy/utils/CsjTools.java b/src/com/qy/utils/CsjTools.java index f0ed9e8..5f74842 100644 --- a/src/com/qy/utils/CsjTools.java +++ b/src/com/qy/utils/CsjTools.java @@ -1,7 +1,6 @@ package com.qy.utils; import com.qy.Interfaces.SmaliApkToolsPath; -import com.qy.ui.EditToDalog; import org.json.JSONArray; 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 csj_Path = "D:\\IdeaProjects\\android_sdk_tools\\demo_2.8.0.2"; private List r_list; + private String packageName = null; 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) { File file = new File(path); String xml = null; @@ -66,19 +84,22 @@ public class CsjTools { } return null; } - private boolean isAppPackageName =false; - public void setUserPackageName(boolean isAppPackageName){ - this.isAppPackageName=isAppPackageName; + + private boolean isAppPackageName = false; + + public void setUserPackageName(boolean isAppPackageName) { + this.isAppPackageName = isAppPackageName; } + private String getPackageName() { try { - if(isAppPackageName) { + if (isAppPackageName) { File apkManifest = new File(apk_Path + File.separator + "AndroidManifest.xml"); BufferedReader reader = new BufferedReader(new FileReader(apkManifest)); String tmp = reader.readLine(); reader.close(); return getXMLValue("package", tmp); - }else{ + } else { return "com.prujwk.jdyphn"; } } catch (Exception e) { @@ -325,30 +346,16 @@ public class CsjTools { //还有最后一个问题,穿山甲的Activity没改 public static void main(String[] args) { - CsjTools tools = new CsjTools(); - tools.build("D:\\IdeaProjects\\android_sdk_tools\\demo_2.8.0.2.apk", - "D:\\IdeaProjects\\android_sdk_tools\\app-release.apk", - new SmaliApkToolsPath() { - @Override - public void smaliPath(String log) { - System.out.println(log); - if (log.startsWith("已出包")) { - 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(); + new CsjTools("C:\\Users\\58381\\Documents\\WeChat Files\\z583819556\\FileStorage\\File\\2020-04\\CasualGame-release.apk" + , "E:\\idea\\android_sdk_tools\\input\\csjDemo\\demo_2.9.0.0.apk" + , "com.abc.test" + , "5700" + , new SmaliApkToolsPath() { + @Override + public void smaliPath(String path) { + System.out.println("打包完成:"+path); + } + }); } }