Wish Android App bundle - BundleTool

Discussion in 'Bugs & wishlist' started by moster67, Apr 28, 2019.

  1. moster67

    moster67 Expert Licensed User

    Just wanted to know if it would be possible to add support for Googles App Bundle.
    In my case, I have a wrapper which includes native libraries. Recently, the native libraries must also include support for 64bit and depending on the native library I have compiled, the apk size can increase dramatically. If one adds also support for all cpu-architectures, the size increases even further.

    The solution seems to be Android's App Bundle. Here is a video about this new feature:

    Here is more information:

    It seems like it can be done without using Android Studio and Gradle, using Google's BundleTool:

    This is why I thought/hoped it could be implemented in B4A too.
    Last edited: Apr 28, 2019
  2. Sasuke Sama

    Sasuke Sama Active Member Licensed User

    would love to see that too
  3. Microinvest

    Microinvest Member Licensed User

    Recently, while uploading in Google play we started to get this type of warnings, as in B4A we generate APK, not AAB (Google bundle):

    "Unoptimised APK


    This APK results in unused code and resources being sent to users. Your app could be smaller if you used the Android App Bundle. By not optimising your app for device configurations, your app is larger to download and install on users' devices than it needs to be. Larger apps see lower installation success rates and take up storage on users' devices.

    We would like to see bundle support as well."
    Last edited: Jun 28, 2019
    Ferdari and Toky Olivier like this.
  4. Erel

    Erel Administrator Staff Member Licensed User

  5. Toky Olivier

    Toky Olivier Member Licensed User

    I wanted also to understand more about this Android App Bundle. I'm sure that Erel will find the best method to integrate it in B4A but just to begin, I create a very little and temporary tool to generate *.aab files with B4J. This is my first B4J app, be indulgent please :)

    It uses Gradle to build apks from B4A projects and also to produce Android App Bundle. It's just a test, if someone can improve it. For now, I tested just one simple project (the included sample) with just "core.jar" as dependency from the B4A Libraries.
    2019-07-02 06_56_27-Gradle build for B4A projects v.1.1.png

    To use it:
    - First, we need Gradle binaries (what I used is the version 4.6: https://downloads.gradle.org/distributions/gradle-4.6-bin.zip). I don't know if it is OK for another versions. This is the first time I played with Gradle too. Extract the file in one folder and then reference it in the B4J app.
    - After, fill all fields: gradle version, android.jar location, B4A installation folder, B4a project file.
    - Compile the B4A project (in B4A or click the button Compile with B4A, it uses B4ABuilder) to produce all java sources
    - Click Compile with Gradle (to produce apks: debug and releases version) - It takes long times sometimes, gradle download all dependencies file (I don't know yet if one can optimize it... ). May be this step is not needed if you want just to produce App Bundle. Apks produced here is like normal Apks (I think, I tested and they work well)
    - Click Create App Bundle to produce App Bundle (sorry, I have no time to test it in Play store yet)

    This is not a complete tool but just a test and to show, may be it is possible... I did it rapidly, may be, there are many bugs too.
    All file produced by this app are in the subfolder "GradleBuild" in the B4A Project Dir. Produced APKs and AAB ar in the folder: ".GradleBuild\build\outputs"

    PS: I am a very newbie in b4j and I don't now yet how to use jshell well... Log data in the TextArea are scrambled, I don't know why?? :eek:

    See enclosed the B4J source file, the very sample B4A sample project and produced apk and aab file with the tool.

    v0.4: Can compile now projects with b4xlibs (eg: X2 Example pack of @Erel). Not yet for Projects with #AdditionalJar directives or AppCompat Project, etc... Many things that I don't understand well yet. To compile X2 Example pack, compile directly in B4A before to execute #CustomBuildAction directive of the Game class. V.04 needs the ArchiverPlusZip library of @Informatix to handle *.b4xlibs

    Attached Files:

    Last edited: Jul 3, 2019
  6. moster67

    moster67 Expert Licensed User

    Looks interesting - many thanks.
    Hopefully next weekend I will have some time to test.
  7. Peter Simpson

    Peter Simpson Expert Licensed User

    Hello @Toky Olivier,
    So I've downloaded all your files and I've given your application a quick try try.

    I compile the test app in B4A, then I click the Compile with Gradle button and it appeared to be downloading dependencies, etc. It creates the \GradleBuild folder in the B4A projects folder, but it does not create the \GradleBuild\build\outputs\ folder, even though it says >> Success!! See the *.apk file int the folder: C:\Users\Peter\.......

    This was just a quick 10 minute test as I have a few other things I must be getting on with, oh yes and my environments are all filled in...
  8. Toky Olivier

    Toky Olivier Member Licensed User

    Hello @Peter Simpson ,
    Thank you for your test. Have you tried running directly in command line the generated batch files? What are outputs?

    >> cd "your GradleBuild folder"
    >> build-apks.bat <== To build with gradle apks
    >> gradlew.bat bundleRelease <== To generate App Bundle
  9. Toky Olivier

    Toky Olivier Member Licensed User

    Last edited: Jul 2, 2019
  10. Peter Simpson

    Peter Simpson Expert Licensed User

  11. Toky Olivier

    Toky Olivier Member Licensed User

    Try v0.4 to compile projects that use b4xlib (example: @Erel's X2 Example pack). Another step, project with #Additionaljar, etc. directives...
  12. Peter Simpson

    Peter Simpson Expert Licensed User

    Same as before, with a basic small app it works perfect, but with a larger app it fails, in my case it fails with the following error.

    xCLVew\GradleBuild\.gradle\vcsWorkingDirs) has not been cleaned up in 0 days
    >> Unknown Error!!! 
    Try to execute this command in command line in the GradleBuild directory: 'build-apks.bat' to look what's wrong
    Last edited: Jul 4, 2019
  13. Erel

    Erel Administrator Staff Member Licensed User

    The result AAB will not have any advantage of the original APK unless you are using a library with large native resources such as ffmpeg. In that case the installed app will be a few mb smaller.
    Toky Olivier likes this.
  14. Peter Simpson

    Peter Simpson Expert Licensed User

    Yes I know I'm testing this for the developer, I just wanted to help the developer to get it working correctly. I develop bespoke applications for clients and not for the play store, so having .aab files is completely irrelevant to me.
    Last edited: Jul 4, 2019
    Toky Olivier and Erel like this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice