去除打包插件机制,直接使用模板打包
去除打包插件机制,直接使用模板打包 编译后的模板文件需要重命名为"template.apk"并放到assets目录下
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package org.autojs.autojs.apkbuilder;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.autojs.autojs.apkbuilder.util.StreamUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -36,7 +38,7 @@ public class ApkPackager {
|
||||
ZipInputStream zis = new ZipInputStream(mApkInputStream);
|
||||
for (ZipEntry e = zis.getNextEntry(); e != null; e = zis.getNextEntry()) {
|
||||
String name = e.getName();
|
||||
if (!e.isDirectory()) {
|
||||
if (!e.isDirectory() && !TextUtils.isEmpty(name)) {
|
||||
File file = new File(mWorkspacePath, name);
|
||||
System.out.println(file);
|
||||
file.getParentFile().mkdirs();
|
||||
|
||||
@@ -34,7 +34,9 @@ import org.autojs.autojs6.R;
|
||||
import org.autojs.autojs6.databinding.ActivityBuildBinding;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -96,7 +98,7 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
||||
if (mSource != null) {
|
||||
setupWithSourceFile(new ScriptFile(mSource));
|
||||
}
|
||||
checkApkBuilderPlugin();
|
||||
// checkApkBuilderPlugin();
|
||||
}
|
||||
|
||||
private void checkApkBuilderPlugin() {
|
||||
@@ -182,8 +184,16 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
||||
}
|
||||
|
||||
void buildApk() {
|
||||
if (!ApkBuilderPluginHelper.isPluginAvailable(this)) {
|
||||
ViewUtils.showToast(this, R.string.text_apk_builder_plugin_unavailable);
|
||||
// if (!ApkBuilderPluginHelper.isPluginAvailable(this)) {
|
||||
// ViewUtils.showToast(this, R.string.text_apk_builder_plugin_unavailable);
|
||||
// return;
|
||||
// }
|
||||
try {
|
||||
if (!Arrays.asList(getAssets().list("")).contains("template.apk")) {
|
||||
return;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Log.e(LOG_TAG, e.getMessage());
|
||||
return;
|
||||
}
|
||||
if (!checkInputs()) {
|
||||
@@ -260,7 +270,8 @@ public class BuildActivity extends BaseActivity implements ApkBuilder.ProgressCa
|
||||
}
|
||||
|
||||
private ApkBuilder callApkBuilder(File tmpDir, File outApk, ApkBuilder.AppConfig appConfig) throws Exception {
|
||||
InputStream templateApk = ApkBuilderPluginHelper.openTemplateApk(BuildActivity.this);
|
||||
// InputStream templateApk = ApkBuilderPluginHelper.openTemplateApk(BuildActivity.this);
|
||||
InputStream templateApk = getAssets().open("template.apk");
|
||||
return new ApkBuilder(templateApk, outApk, tmpDir.getPath())
|
||||
.setProgressCallback(BuildActivity.this)
|
||||
.prepare()
|
||||
|
||||
Reference in New Issue
Block a user