新增自动打包程序

修复穿山甲打资源包问题
This commit is contained in:
2020-03-13 17:30:40 +08:00
parent 561177d0f4
commit c43093b119
10 changed files with 647 additions and 198 deletions

View File

@@ -67,6 +67,18 @@ public class CsjTools {
return null;
}
private String getPackageName() {
try {
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);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private void outManifest() {
try {
@@ -77,7 +89,7 @@ public class CsjTools {
reader.close();
String apkPackage = getXMLValue("package", tmp);
System.out.println(apkPackage);
_log.smaliPath("获取到APK包名"+apkPackage);
_log.smaliPath("获取到APK包名" + apkPackage);
reader = new BufferedReader(new FileReader(demoManifest));
tmp = reader.readLine();
String manifest = tmp.replace(getXMLValue("package", tmp), apkPackage) + "\n";
@@ -204,8 +216,8 @@ public class CsjTools {
}
outManifest();
File csjRes = new File("csj" + File.separator + "csc.apk");
if (!new File("csj/").exists()) {
new File("csj/").mkdirs();
if (!new File("csj").exists()) {
new File("csj").mkdirs();
}
SmaliUtils utils = new SmaliUtils();
_log.smaliPath("资源包制作完成开始打包为apk");
@@ -225,17 +237,17 @@ public class CsjTools {
public void build(String csjPath, String apkPath, SmaliApkToolsPath log) {
time = System.currentTimeMillis();
_log=log;
unPackageCSJ=false;
_log = log;
unPackageCSJ = false;
File csjFile = new File(csjPath);
if (new File(csjFile.getName().replace(".apk", "")).exists()) {
System.out.println(">?>>"+new File(csjFile.getName().replace(".apk", "")).getAbsolutePath());
System.out.println(">?>>" + new File(csjFile.getName().replace(".apk", "")).getAbsolutePath());
unPackageCSJ = true;
csj_Path = new File(csjFile.getName().replace(".apk", "")).getAbsolutePath();
csj_res = csj_Path + File.separator + "res" + File.separator + "values";
}
SmaliUtils utils = new SmaliUtils();
// Tools.deleteFiles(new File("").getAbsolutePath() + File.separator + new File(csjPath).getName().replace(".apk", File.separator));
// Tools.deleteFiles(new File("").getAbsolutePath() + File.separator + new File(csjPath).getName().replace(".apk", File.separator));
Tools.deleteFiles(new File("").getAbsolutePath() + File.separator + new File(apkPath).getName().replace(".apk", File.separator));
new Thread(new Runnable() {
@Override
@@ -272,7 +284,7 @@ public class CsjTools {
new Thread(new Runnable() {
@Override
public void run() {
new AutoRandomAdSDK().startNotUnPackage(path, new SmaliApkToolsPath() {
new AutoRandomAdSDK().startNotUnPackage(path, getPackageName(), new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
_log.smaliPath("穿山甲修改完成");
@@ -303,15 +315,6 @@ public class CsjTools {
//还有最后一个问题穿山甲的Activity没改
public static void main(String[] args) {
if (false) {
new AutoRandomAdSDK().startNotUnPackage("D:\\IdeaProjects\\android_sdk_tools\\demo_2.8.0.2", new SmaliApkToolsPath() {
@Override
public void smaliPath(String path) {
System.out.println("-------" + path);
}
});
return;
}
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",