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