bundletool icon indicating copy to clipboard operation
bundletool copied to clipboard

Request: offer conversion of AAB to APK for Android apps, too

Open AndroidDeveloperLB opened this issue 5 years ago • 10 comments

Is your feature request related to a problem? Please describe. If we generate AAB file to be used by devices right in them, it's impossible. Each person who gets the "AAB" file needs to use this tool to convert the app into APK file. I know AAB isn't intended to be used for this purpose of sharing apps installations, but that's the nearest thing we can do to simulate installation from the Play Store, without the Play Store.

Describe the solution you'd like A way to use this tool on Android OS itself, to convert the AAB file into APK file, to be installed&run on it, just as if it was from the Play Store. All this without the use of a PC to make a special solution for this specific device. If this is already possible and by the rules of the Play Store, please let me know.

Describe alternatives you've considered Of course, instead of exporting to AAB file, the IDE allows to export to APK, but then you lose the entire testing of the AAB file, because split APK files are supposed to install only a part of what's inside the AAB file.

Additional context It could be nice to even install the AAB file directly on the device (without the help of a PC and USB), without conversion.

AndroidDeveloperLB avatar Jun 30 '20 07:06 AndroidDeveloperLB

The AAB will never be installable, it's on purpose a non-installable format to decouple the publishing format from the Android platform format. We have however introduced the APK Set files (extension .apks) that bundletool generates with the command build-apks. You can share this file and then let people install it on their device using bundletool's install-apks command.

Another simpler way is to use Internal App Sharing: you upload an AAB, and you get immediately a link back that you can share with your testers. No need for tracks, no need to modify the versionCode or even sign the AAB, it's very lightweight.

plecesne avatar Jun 30 '20 08:06 plecesne

Why won't it ever be installable? Technically if it's possible to convert it to something that it can be installed, it should be possible to install it directly, too. Can bundletool be used right on Android OS though? Can it handle files there, even without a file-path (using InputStream) ? Or via other way that could re-create an InputStream (Uri for example) ?

The link you've provided is of the Play Store. I was talking about a solution that requires only the device itself, and the AAB file (and the app that will be able to handle it). No Internet connection at all.

AndroidDeveloperLB avatar Jun 30 '20 08:06 AndroidDeveloperLB

Even though it's technically possible, it's against the philosophy of the App Bundle: as I mentioned, the App Bundle is a publishing format, it's not meant to be installed.

If you need an offline solution, then generating the .apks file using bundletool and sharing that file is probably your best option today.

plecesne avatar Jun 30 '20 08:06 plecesne

OK, so back to the request: Can I please use bundletool within Android device itself, on my own app, to convert it to something that can be installed right for this exact device? Can it handle not just file-path, but other formats (InputStream, Uri,...) ?

AndroidDeveloperLB avatar Jun 30 '20 08:06 AndroidDeveloperLB

Could you explain why the .apks file approach I've mentioned doesn't work for you?

plecesne avatar Jun 30 '20 08:06 plecesne

How do I generate this file within Android OS, given an AAB file ? Is this tool available as a library? This was the request, to be able to use this tool as a library within an Android app, within Android. Sadly the bundletool is quite large to be inserted into an app, so that's another reason to request this as a library (might be smaller).

The command for PC as as written here, as such, right:

java -jar bundletool.jar build-apks --bundle=theAppBundle.aab --output=theApksFile.apks

?

I've tried it on PC. Seems to work well. But how would I install it on the device? After I generate it...

Why don't we have this option on the IDE, BTW? Why not being able to export the app to multiple formats? And why can't we upload this file to the Play Store instead (signed, of course) ?

As for your question: When you upload the app bundle to the Play Store, you upload the AAB file. It should be the exact same that you try on devices. Creating more files on the way takes time, takes more steps, and you need to be very careful to say that both are of the same version. If you generate the AAB file and the APKS file, you need to make sure that both are of the exact same version. The less files, the less time consumed and the less confusion as there is no need to match between them.

AndroidDeveloperLB avatar Jun 30 '20 08:06 AndroidDeveloperLB

Bundletool cannot run on Android today unfortunately.

But how would I install it on the device? After I generate it...

java -jar bundletool.jar install-apks --apks=theApksFile.apks`

You can run the following command to get more details about the install-apks command and the various flags.

java -jar bundletool.jar help install-apks

Why don't we have this option on the IDE, BTW?

Android Studio has the option to deploy APKs generated from the App Bundle. When you open your "Run/Debug Configurations", in the Installation Options, you can select "Deploy: APK from app bundle" (instead of "Default APK").

plecesne avatar Jun 30 '20 09:06 plecesne

Seeing that (sadly) Google will force developers to switch to only app-bundle solution on the Play Store (link here and here), I think it's important to make everything that's related to app-bundle to easy to handle, official, standard, that can be installed and launched without any additional tool, on both PC and on Android device. It should be as easy to install as stand-alone APK file. It should be easy to share. It should be easy to handle via official API via Android OS too. Currently I have a batch file to install APK files, but it works only for stand-alone APK files. Not for split-APK files. I really wish I could have one that works for all types that you've noticed that exist: AAB, APKS, and APK files that are in the same folder (example is when you extract the APKS file).

Even the "apks" is supposed to be an official file format, but it is already taken by a third party app (SAI, here), and of course it can't use it (has some issue with it).

It became a huge mess of file formats. There is AAB, APKS (here and on SAI app, and both are different), XAPK (of APKPure, and it can hold OBB files too), and APKM (of APK mirror website, which is very inefficient as it's encoded heavily). I'm sure there are more.

Not only that, but the Android framework itself can't parse split APK files. Only the main one, and only via file-path.

I really wish there could be one official standard of split APKs that Google publishes, that all can use on both PC and Android, easily, just as we can for stand-alone APK files. It's very frustrating. I even requested it on the issue tracker. Now with Android R Google has a chance to publish a file format that the OS can handle on its own. We should be able to open APKS file (or whatever the file format will be) right on the OS. We should be able to use adb pm install somefile.apks , just like APK file.

About the option of Android Studio, I meant not just installing, but the exporting to "apks" file. If "apks" file is more flexible and is the one to use to install split-apk files, it should be available too. Maybe when generating the "aab" file, it could offer to generate this one too.

AndroidDeveloperLB avatar Jun 30 '20 10:06 AndroidDeveloperLB

Thank you for taking the time of writing this detailed feedback.

I'll keep this FR while our team investigates ways to address the issues you mention.

plecesne avatar Jun 30 '20 10:06 plecesne

I hope you can pass it forward to Google developers who work on Android itself, too. The more there is a push for split-APK files, the more this will become a mess.

AndroidDeveloperLB avatar Jun 30 '20 10:06 AndroidDeveloperLB