Skip to content

Commit

Permalink
Signed-off-by: para <para>
Browse files Browse the repository at this point in the history
  • Loading branch information
para committed May 20, 2020
0 parents commit 02a6e41
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 0 deletions.
85 changes: 85 additions & 0 deletions HowtoBuildApkToolJar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#### springboot 下 java 调用 apktool
+ 从官网下apktool.jar
+ 把依赖加入gradle
dependencies 下添加
```
compile files('tool/apktool.jar')
```
但是apktool和springboot 里面的依赖冲突了 报 **java.lang.NoSuchMethodError**
从报错种找到相关包:

+ org.yaml.snakeyaml
springboot 下是1.25
apktool 下是 1.12
好吧
+ 要么编译springboot 要么编译 apktool
+ 本着新版本应该会向老版本兼容的原则 尝试把 apktool 的 snakeyaml 从1.12提升到1.25
#### 编译 apktool
+ github 下载源码
参考编译说明:
https://ibotpeaches.github.io/Apktool/build/
+ 修改 build.gradle Line:122 切换版本
```
snakeyaml: 'org.yaml:snakeyaml:1.12:android',
修改为
snakeyaml: 'org.yaml:snakeyaml:1.25:android',
```
+ gradlew.bat 秒闪后退出 看不清报错信息
修改gradlew.bat 在 :execute 后加 pause 看报错信息
```
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
pause
```
+ 看到原因 Unsupported class file major version 57
好吧 jdk13 不支持 换jdk 8
重新编译成功

+ 文件在: **brut.apktool/apktool-cli**, 没看到这句话 纠结了1kb好久
```
After build completes you should have a jar file at: ./brut.apktool/apktool-cli/build/libs/apktool-xxxxx.jar
```

```
import brut.androlib.Androlib;
import brut.androlib.AndrolibException;
import brut.androlib.ApkDecoder;
import brut.common.BrutException;
import brut.directory.DirectoryException;
import java.io.File;
import java.io.IOException;
public class ApkToolKit {
static String rootPath = GetPath.getRootDir();
static String appDir = rootPath + "apk/app";
static String appDir2 = rootPath + "apk/app2";
static String outApk = rootPath + "apk/app.apk";
public static void Build(){
Androlib instance = new Androlib();
try {
instance.build(new File(appDir) , new File(outApk));
} catch (BrutException e) {
e.printStackTrace();
}
System.out.println("buildApk done");
}
public static void Decde(){
try {
File inFile = new File(outApk);
ApkDecoder decoder = new ApkDecoder();
decoder.setOutDir(new File(appDir2));
decoder.setApkFile(inFile);
decoder.decode();
} catch (IOException|AndrolibException | DirectoryException e) {
e.printStackTrace();
}
}
}
```
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# build Apk with html
[中文点这里](README_zh.md)
#### Start
+ build Apk with html, which can be local(index_html) or network(http)
+ Using HTML as UI, can be used as server or local
+ Three ways to local_html: sinlge-file, zip or folders(only support chrome)

#### require
+ java 1.8+

#### theory
+ Decompilation through apktool[^1]
+ Modify decompiled content
+ Recompile and sign
[^1]: 1 apktool.jar -> org.yaml.snakeyaml and springboot Version conflict (springboot snakeyaml-1.25, apktool snakeyaml-1.12) Must compile by yourself See [How to Build ApkToolJar](HowtoBuildApkToolJar.md)

#### todo
+ Support for multi-user simultaneous use
+ UI adjustment
+ Support package name modification
+ Support version modification
+ More about WebView features
- Navigation bar
- progress bar
- etc..

#### How to use
+ Installing the Java environment 1.8 +
+ download releases
+ java -jar html2apk-1.0.jar
+ defaul port 80, if u wana modify port:
java -jar demo.jar --server.port=8080
+ you must have apk-template dir : /apk/*
+ you must have ui dir : /html/*

#### How to Build
+ ./gradlew for unix based systems or gradlew.bat for windows.
+ After build completes you should have a jar file at: build/libs/html2apk-xxx.jar
40 changes: 40 additions & 0 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# html 生成 Apk
#### 简介

+ 使用一个本地/网络的网页, 生成一个apk

+ 使用html作为UI, 可以做服务器使用, 也可以在本地使用

+ 支持使用单index.html 压缩包 和 文件夹(仅支持chrome) 3种方式

#### 需要环境
java 1.8+

#### 原理

+ 通过apktool[^1]反编译
+ 修改反编译后的内容
+ 重新编译并签名

[^1]: 1 apktool.jar 由于 org.yaml.snakeyaml 和springboot 下的版本冲突(springboot 下是1.25 apktool 下是 1.12) 必须自己编译 详见 [如何编译apktool.jar](HowtoBuildApkToolJar.md)

#### todo
+ 多用户同时使用的支持
+ UI 调整
+ 支持包名的修改
+ 支持版本号修改
+ 更多关于webview的功能
- 导航条
- 进度条
- 其他的东西
#### 如何使用
+ 安装java 环境1.8 +
+ 下载realse
+ java -jar html2apk-1.0.jar
+ 默认80 如果你想修改端口:
java -jar demo.jar --server.port=8080
+ 需包含 apk 的模板文件夹 apk
+ 需包含 前端UI文件夹 html
#### 如何编译 How to Build
+ ./gradlew for unix based systems or gradlew.bat for windows.
+ After build completes you should have a jar file at: build/libs/html2apk-xxx.jar

0 comments on commit 02a6e41

Please sign in to comment.