从 aab 文件生成 Apk 文件(android app bundle) [英] Generate Apk file from aab file (android app bundle)

查看:84
本文介绍了从 aab 文件生成 Apk 文件(android app bundle)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法通过终端或使用android studio从android app Bundle生成apk文件?

Is there any way to generate an apk file from android app Bundle via terminal or using android studio?

推荐答案

默认情况下,IDE 不使用应用程序包将您的应用程序部署到本地测试设备

By default, the IDE does not use app bundles to deploy your app to a local device for testing

参考bundletool 命令

对于调试 apk 命令,

For Debug apk command,

bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks

对于发布 apk 命令,

For Release apk command,

bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks
--ks=/MyApp/keystore.jks
--ks-pass=file:/MyApp/keystore.pwd
--ks-key-alias=MyKeyAlias
--key-pass=file:/MyApp/key.pwd

我在测试 aab 的发布版本时一直在使用以下命令(我希望它也能帮助其他人):

I have been using following commands while testing my release build for aab(I hope it helps others too):

  1. Github 存储库 下载 bundletool jar 文件(最新版本 > 资产 > bundletool-all-version.jar 文件).将该文件重命名为 bundletool.jar

  1. Download bundletool jar file from Github Repository (Latest release > Assets > bundletool-all-version.jar file). Rename that file to bundletool.jar

从 Android Studio 生成 aab 文件,例如:myapp-release.aab

Generate your aab file from Android Studio eg: myapp-release.aab

运行以下命令:

java -jar "path/to/bundletool.jar" build-apks --bundle=myapp-release.aab --output=myapp.apks --ks="/path/to/myapp-release.keystore" --ks-pass=pass:myapp-keystore-pass --ks-key-alias=myapp-alias --key-pass=pass:myapp-alias-pass

  • myapp.apks 文件将被生成

    确保您的设备已连接到您的机器

    Make sure your device is connected to your machine

    现在运行以下命令将其安装到您的设备上:

    Now run following command to install it on your device:

    java -jar "path/to/bundletool.jar" install-apks --apks=myapp.apks
    

  • 编辑 2:

    如果您需要从 .aab 文件中提取单个 .apk 文件,您可以添加额外的参数 --mode=universalbundletool 命令:

    If you need to extract a single .apk file from the .aab file, you can add a extra param --mode=universal to the bundletool command:

    bundletool build-apks --bundle=/MyApp/my_app.aab --output=/MyApp/my_app.apks \
        --mode=universal \
        --ks=/MyApp/keystore.jks \
        --ks-pass=file:/MyApp/keystore.pwd \
        --ks-key-alias=MyKeyAlias \
        --key-pass=file:/MyApp/key.pwd
    

    并执行

    unzip -p /MyApp/my_app.apks universal.apk > /MyApp/my_app.apk
    

    这将生成一个 /MyApp/my_app.apk 文件,该文件可由任何设备应用安装程序共享和安装

    this will generate a single a /MyApp/my_app.apk file that can be shared an installed by any device app installer

    这篇关于从 aab 文件生成 Apk 文件(android app bundle)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆