app bundle and bundletool. 關於aab安裝問題

google 有說明年開始強制使用app bundle.

不然不准更新app.

但是產出的apk不再是apk了,而是aab.

C:\release>adb install 6.aab
Performing Streamed Install
adb.exe: filename doesn't end .apk or .apex: 6.aab
 

不能透過adb install....

so, google 發表一個新tool: 去download bundletool...因為是java跨平台都可執行.

https://github.com/google/bundletool/releases

 

You can extract the apks files from the aab file using the bundletool command.

https://developer.android.com/studio/command-line/bundletool


To generate an APK set for all device configurations (signed with a debug key) you can use: 

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


To deploy your app from an APK set, use the install-apks 

bundletool install-apks --apks=/MyApp/my_app.apks

test: 

C:\release>java -jar bundletool.jar build-apks --bundle=6.aab --output=out_6.apks
INFO: The APKs will be signed with the debug keystore found at 'C:\Users\mark\.android\debug.keystore'.
 

還是失敗,還要指定key才可以...

 For Release apk command,



example 1:
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

example 2:
java -jar bundletool-all-0.3.3.jar build-apks --bundle=bundle.aab --output=app.apks --ks=my-release-key.keystore --ks-key-alias=your_alias --ks-pass=pass:your_password

Arguments:

  • --bundle -> Android Bundle .aab file
  • --output -> Destination and file name for the generated apk file
  • --ks -> Keystore file used to generate the Android Bundle
  • --ks-key-alias -> Alias for keystore file
  • --ks-pass -> Password for Alias file (Please note the 'pass' prefix before password value)

注意--ks-pass:一定要有pass: or file: 前置字串不然會出現: Error: Passwords must be prefixed with "pass:" or "file:".

test :成功產生apks.

但.apks還是不能用adb install ...

C:\release>adb install out_6.apks
Performing Streamed Install
adb.exe: filename doesn't end .apk or .apex: out_6.apks

改附檔名看看:  apks--> apk

C:\release>adb install out_6.apk
Performing Streamed Install
adb: failed to install out_6.apk: Failure [INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: Failed to parse /data/app/vmdl18994
28861.tmp/base.apk: AndroidManifest.xml]


失敗!!! apks改副檔名apk是不行用adb install的。.

還是用bundletool

Now run following command to install it on your device:

C:\release>java -jar ./bundletool.jar install-apks --apks=out_6.apks
The APKs have been extracted in the directory: c:\Temp\13253261590135541

成功安裝....檢查手機.

而且我還發現一個app bundle好處,pro-guard file會內含在.aab內,自動上傳到google play console.

以後不用擔心找不到mapping資料夾了.



--->後記: 不過還是有問題,產生出的apk使用的簽署金鑰不是google自動簽署生產用的,是發佈者的發布金鑰,

所以地圖都無法顯示.而真正的簽署金鑰是存放在google server那,所以我拿不到. 

--> for debug: 查詢自己的debug key:

keytool -list -v -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore


 

以前apk時,可以download derived apk,

Go to "Release management > Artifact library", then when clicking on the download icon, it will open a window with the ability to download the APK signed with the app signing key; it's called "Derived APK".

但現在用aab都不可以了.

只好改用google play console 新功能: Internal app sharing

 


 感覺真的變複雜了,

Not Found

Error 404

 

目前還是無法安裝成功....再試試

 而且還要是發佈後的才允許內部測試..


 如果是選自己機型的: 會出現好多奇怪apk....

如果只安裝這base.apk會出現問題...

C:\release>adb install base.apk
* daemon not running; starting now at tcp:5037
* daemon started successfully
Performing Streamed Install
adb: failed to install base.apk: Failure [INSTALL_FAILED_VERIFICATION_FAILURE]

答案也不是這個.

 

最後還是用 先發佈app,但是不用等google play人員審核....

這個事後上傳一開始的.aab就好.

這連結很奇怪,很長.如果貼在電腦上看會是這畫面: 所以一定要貼在手機上.

但是我貼在手機上卻出現:

還是失敗...

再試試~~~

好像要一開始放在internal test track才能用這功能,我是放在beta track...故不能用...

只好下次再試試.


 

新的app bundle 功能變好複雜,以前的apk管理方式都不能用了.

探索(explore)
 


最後:再一次download 自己手機的apk at "Download device-specific APKs" ,這是一個zip檔,解壓縮到一個資料夾.

再用adb特殊指令安裝

You can install these APKs using the adb install-multiple command: 

adb install-multiple [-lrtsdpg] <file...>
                             - push this package file to the device and install it
                               (-l: forward lock application)
                               (-r: replace existing application)
                               (-t: allow test packages)
                               (-s: install application on sdcard)
                               (-d: allow version code downgrade)
                               (-p: partial application install)
                               (-g: grant all runtime permissions) 

adb install-multiple base.apk config.en.apk config.xxhdpi.apk

我是用:

這次地圖有顯現了,使用到正確的google derived 簽署金鑰.

但下次可以用用看internal test方式看看.

----

更新: 可用新方法:https://markappdesign.blogspot.com/2021/09/android-app-bundle-install-aab-to-device.html

 






留言

這個網誌中的熱門文章

最爛的銀行服務-玉山銀行

Mark App Design Apps - Terms and Privacy Policy (服務條款,隱私權政策)

SMR疊瓦式hdd致命缺陷被解決????!!!

ios app 上架時app icon要注意事項

更改google drive預設存放目錄位置Change Google Drive Default Folder Location in Windows

google play 正式發布前測試報告...非常好用.

舊有app在Android 12 閃退問題& app Splash screens

關於google play console app應用程式簽署

Google Play badge徽章產生器