Reputation: 182048
The assets in my Flutter app are about 300 MB in total (lots of media files, which are the essence of the app and can't sensibly be trimmed down).
As I understand it, there are two ways to upload apps to the Play Store:
For APKs, the way to work around this limit is APK Expansion Files (often "obb" files), which can be up to 2 GB. I could try to get this to work with Flutter, but the APK delivery method is somewhat deprecated, and has other drawbacks like bloating the install size with unused binaries. So I'd rather not use this approach.
For App Bundles, a similar mechanism exists in the form of Dynamic Asset Delivery. There are three options, depending on when the user will download the asset pack: during installation, right after installation, or on demand. The install-time
option sounds most transparent and simple and is limited to 1 GB, so it would be great for my use case.
Sadly, Flutter does not yet support Dynamic Asset Delivery. Fortunately, when using install-time
delivery, it looks like these assets become available through the regular AssetManager
class provided by the system. At first I thought Flutter might pick them up without having to write any Java/Kotlin code, but no, it uses its own assets mechanism, and there is nothing but a proposal for getting access to the AssetManager
. So I'd have to do some legwork myself to interact with the Java world, but it sounds doable.
To create the bundle in the first place, I followed these steps. Now how do I run the app?
flutter run
produces no errors, but doesn't seem to install the asset bundle, so all my assets are missing during testing. I suspect it builds an APK directly, rather than building an app bundle and then creating an APK from that. And because IntelliJ IDEA also seems to invoke flutter run
or something similar, my debugger and other IDE integration are useless now.
flutter build appbundle
seems to work and spits out an .aab
file. For testing, presumably I could use bundletool to create an APK out of this and install it, but that would be a terrible development experience compared to Flutter's usual sub-second hot reload.
Is this a dead end? Is there another way to deliver an app with large assets through the Play Store? Please note, I'm not interested in external hosting unless it offers free and (near) unlimited traffic, because this is a noncommercial project.
(On the App Store for iOS, the limit seems to be 4 GB, no questions asked. Whot?)
Upvotes: 8
Views: 2119
Reputation: 1829
For deploying, this is now supported by using Deferred Components (which is introduced in around Mar 2021). Technical details in Flutter wiki
With Deferred Components you can distribute large assets through Play Feature Delivery (no Play Assets Delivery yet).
In my opinion the documentation is a bit lacking (especially for using feature to deliver assets only), but after digging into source code + trial and error, I can distribute an app with 150MB+ assets as dynamic feature through Play Store (to testers).
For testing, I can't find another way other than bundletool as you mentioned. What make it worse for me is some Deferred Components APIs seem to work differently on the apks built by bundletool and the apk built by Play Store, so testing can be even more time consuming and painful than it looks.
Upvotes: 0