开源Android apk转aab工具

功能

  1. 自动化将apk转为aab文件.
  2. 自动化实现打包smali,签名,安装.

用法

配置文件(config.toml )

复制代码
[sign]
#"exec command: java -jar {} build-apks --bundle {} --output {} --ks {} --ks-pass pass:{} --ks-key-alias {} --key-pass pass:{}", config.jar.bundletool_path, aab_path.to_string_lossy(), apks_path.to_string_lossy(), config.sign.keystore, config.sign.keystore_pass, config.sign.keystore_key_alias, config.sign.keystore_key_pass
keystore = "your_keystore_path/yourkeystore.jks"
keystore_pass= "your keystore password"
keystore_key_alias="your keystore alias"
keystore_key_pass="your key password"

[apk]
#"exec command: java -jar {} d {} -s -o {}", config.jar.apktool_path, config.apk.apk_path, config.apk.apk_outdir
apk_path="your_apk_path/yourapk.apk"
apk_outdir="your output dir"
#"exec command: aapt2 link --proto-format -o {} -I {} --min-sdk-version {} --target-sdk-version {} --version-code {} --version-name {} --manifest {} -R {} --auto-add-overlay",base_apk_path.to_string_lossy(), config.jar.android_jar_path, config.apk.min_sdk_version, config.apk.target_sdk_version, config.apk.version_code, config.apk.version_name,manifest_path.to_string_lossy(),res_zip_path.to_string_lossy()
min_sdk_version="21"
target_sdk_version="31"
version_code="101"
version_name="1.0.1"
#"{}_{}-sign.apk", time, config.apk.app_name
app_name="your app name"

[jar]
#"exec command: java -jar {} d {} -s -o {}", config.jar.apktool_path, config.apk.apk_path, config.apk.apk_outdir
apktool_path="your_apktool_path/apktool.jar"
#"exec command: aapt2 link --proto-format -o {} -I {} --min-sdk-version {} --target-sdk-version {} --version-code {} --version-name {} --manifest {} -R {} --auto-add-overlay",base_apk_path.to_string_lossy(), config.jar.android_jar_path, config.apk.min_sdk_version, config.apk.target_sdk_version, config.apk.version_code, config.apk.version_name,manifest_path.to_string_lossy(),res_zip_path.to_string_lossy()
bundletool_path="your_bundletool_path/bundletool-all-1.15.2.jar"
android_jar_path="your_sdkpath/sdk/platforms/android-31/android.jar"

[config]
#"exec command: adb install -r {}", apk_sign_path.to_string_lossy().to_string()
install = true
#"exec command: adb shell am start -n {}", config.config.main_activity
launch = true
main_activity = "your_package/your_launcher_activity"
#"exec command: java -jar {} build-bundle --modules {} --output {} --config={}", config.jar.bundletool_path, zip_path.to_string_lossy(), aab_path.to_string_lossy(), config.config.bundletool_config_path)
bundletool_config_path = "bundletool config file path"

[build_apk]
#"exec command: java -jar {} b {} -o {}", config.jar.apktool_path, config.build_apk.app_path, apk_unsign_path.to_string_lossy().to_string();
app_path="your smali dir"

apk转aab命令

复制代码
./abtool_cli -c config.toml -a aab

config.toml为配置文件. aab为指定将apk转为aab流程.

主要流程如下:

复制代码
  let outdir = Path::new(config.apk.apk_outdir.as_str());

    if !outdir.exists() {
        decode_apk(&config)?;
    }

    compile_resources(&config)?;
    link_resources(&config)?;
    unzip_apk(&config)?;
    copy_resources(&config)?;
    zip_resources(&config)?;
    compile_app_bundle(&config, time)?;
    let aab_name = sign_app_bundle(&config, time)?;

    if config.config.install {
        build_apks(&config, time)?;
        install_apks(&config)?;
        if config.config.launch {
            launch_app(&config)?;
        }
    }

编译apk

复制代码
./abtool_cli -c config.toml -a apk

smali工程编译成apk并签名.

主要流程如下:

复制代码
    apktool_build(&config, time)?;
    zipalign(&config, time)?;
    let apk_name = apksigner(&config, time)?;
    if config.config.install {
        install_apk(&config, time)?;
        if config.config.launch {
            launch_app(&config)?;
        }
    }

源码

  1. 编译

    cargo build -p abtool_cli --release

  2. upx压缩(可选)
    target/release

    upx --best --lzma abtool_cli

压缩后linux平台二进制文件大小在880k左右.

  1. 从源码运行

    cargo run -p abtool_cli -- -c your_config_file_path/config.toml -a aab

跨平台

目前在linux设备上完美运行,理论上已经适配了Windowsmac OS系统, 但未能拿到相关设备进行测试.

github项目地址:https://github.com/tangxuesong6/abtool.

相关推荐
2501_9159214331 分钟前
iOS 是开源的吗?苹果系统的封闭与开放边界全解析(含开发与开心上架(Appuploader)实战)
android·ios·小程序·uni-app·开源·iphone·webview
西京刀客1 小时前
开源 ETL(Extract,Transform,Load)工具之Apache Hop
开源·apache·etl·hop
allk551 小时前
OkHttp源码解析(一)
android·okhttp
allk551 小时前
OkHttp源码解析(二)
android·okhttp
CoderJia程序员甲4 小时前
GitHub 热榜项目 - 日榜(2025-10-11)
ai·开源·github·ai编程·github热榜
2501_915909064 小时前
原生 iOS 开发全流程实战,Swift 技术栈、工程结构、自动化上传与上架发布指南
android·ios·小程序·uni-app·自动化·iphone·swift
2501_915909064 小时前
苹果软件混淆与 iOS 代码加固趋势,IPA 加密、应用防反编译与无源码保护的工程化演进
android·ios·小程序·https·uni-app·iphone·webview
2501_916007474 小时前
苹果软件混淆与 iOS 应用加固实录,从被逆向到 IPA 文件防反编译与无源码混淆解决方案
android·ios·小程序·https·uni-app·iphone·webview
介一安全5 小时前
【Frida Android】基础篇6:Java层Hook基础——创建类实例、方法重载、搜索运行时实例
android·java·网络安全·逆向·安全性测试·frida
l1t6 小时前
测试DuckDB电子表格读取插件rusty_sheet 0.2版
数据库·rust·插件·xlsx·duckdb