godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.17k stars 98 forks source link

Add Android Application Bundle option in the Android export template options #342

Closed mickael-h closed 4 years ago

mickael-h commented 4 years ago

Describe the project you are working on: Mobile game Describe the problem or limitation you are having in your project: I want to export an AAB bundle for the play store, but the export template only allows to export an APK file Describe how this feature / enhancement will help you overcome this problem or limitation: I would be able to use the AAB format to send to the Google play store, which would allow me to get more lightweight applications. Show a mock up screenshots/video or a flow diagram explaining how your proposal will work: https://i.imgur.com/AIRZdLO.png Describe implementation detail for your proposal (in code), if possible: No idea, to be honest If this enhancement will not be used often, can it be worked around with a few lines of script?: I wish Is there a reason why this should be core and not an add-on in the asset library?: It's not an asset

Calinou commented 4 years ago

See also https://github.com/godotengine/godot/issues/30711. Note that you can already perform the splitting manually using Google Play's multiple APK support.

mickael-h commented 4 years ago

Yeah I know. It's just that AAB files are very lightweight in comparison and I also fear Google might make it mandatory in the near future, considering the big warning sign they show you when you upload an APK file to the Play Store. When I think about it, it mustn't be very hard to implement. All you really need to do is to replace the gradlew assembleRelease command with gradlew bundleRelease...

Calinou commented 4 years ago

@mickael-h As of 3.2, we now have two ways to export projects for Android: the old way, where you download an APK export template and use it to export a project, and the new way, where you download a Gradle project bundle that contains just the native library (.so) and build the Java part before exporting.

I don't know whether we intend to support AAB when exporting using "the old way", but if we do, that means it'll be more work to support it. Also, this stuff needs to be tested to make sure it works with third-party modules.

@m4gr3d Do you know what it'd take to support exporting a project into an AAB using "the new way"? Thanks in advance :slightly_smiling_face:

alexzheng commented 4 years ago

Supporting AAB using the new export way would be enough. Hope it would be available soon.

neverdieboy commented 4 years ago

Hi, recently tried to publish my app in Google Play, and appeared the same problem with Android App Bundle. So now I just can`t publish an app without it. Hope Godot 3.2 will support it, it will be really good

mickael-h commented 4 years ago

@neverdieboy That's weird... you should be able to publish an APK. For the moment, Google only recommends you to use an AAB, but it's not mandatory.

neverdieboy commented 4 years ago

@neverdieboy That's weird... you should be able to publish an APK. For the moment, Google only recommends you to use an AAB, but it's not mandatory.

Maybe I cant understand something. I attached screens, maybe you can help me, because I just can`t start rollout. Без имени-2 Без имени-3

mickael-h commented 4 years ago

@neverdieboy Yeah, that's just a warning. The reason why you can't deploy is because you have uncompleted sections in your app project. You need to make those green in order to deploy your app. image

neverdieboy commented 4 years ago

@mickael-h Oh, I just didn`t think about that, thanks a lot. First time publishing)

bobbles911 commented 4 years ago

+1, this would be a nice feature to easily reduce app sizes. Multiple APKs is possible but more complex having to deal with version numbers

TheNeoGameFactory commented 4 years ago

Godot need this Feature, now.

https://www.androidpolice.com/2020/06/12/google-play-store-will-make-app-bundles-a-requirement-in-2021/?amp

m4gr3d commented 4 years ago

@TheNeoGameFactory we'll be working on this feature for Godot 3.2.3.

amanj120 commented 4 years ago

I opened a similar issue earlier today to go alongside an proof of concept PR (#39761) I made, and I was told to paste my proposal here.

Describe the project you are working on:

Android App Bundles (AABs) are Google’s preferred method of publishing Android apps to the Google Play Store. Starting sometime in 2021, they will be the only way to publish. The best way to build an AAB is to use the Android Gradle Plugin. This project aims to modify the existing “Use Custom Build” process in Godot to create self-contained Gradle projects.

Describe the problem or limitation you are having in your project:

Currently, there is no way for a Godot developer to build an AAB. The Gradle project created by the existing custom build is incomplete: it has no assets, an incomplete resource table, and an incomplete Android Manifest file. This means that a developer cannot use Gradle commands to build their game as an APK or an AAB; they must rely on the editor.

Describe the feature / enhancement and how it helps to overcome the problem or limitation:

This proposal changes the Android “Use Custom Build” from building and then updating a template APK to performing the entire build using Gradle. With this change in place it’s possible to add an “Export AAB” checkbox to the UI that will result in Godot exporting an AAB. This change will also open the door to future enhancements, such as Play Asset Delivery support.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

When a user checks “Use Custom Build” in their Android project and then clicks “Export Project”, the Godot engine will now use a different approach to generate a custom build:

  1. The exporting script will first check that the following are true: a. The res://android directory exists b. There is a path to the Android SDK c. The version of Godot matches the version of the custom build template

  2. The exporting script will look for the specified icon files for the game, and then it will appropriately resize the icon(s), create res://android/build/res/mipmap folders, and copy the resized icons into those folders. This is what the _copy_icons_to_gradle_project and _resize_launcher_icon functions are for a. The store_file_in_gradle_project method is used to store files inside the gradle project (in the res://android/build directory)

  3. The exporting script will create a new Android Manifest file in a separate directory. This manifest file will be merged with the manifest file in the root directory during build time by passing in command line parameters to gradle.

  4. The exporting script goes through all of the assets in the res:// directory that are necessary for the game, and it stores them inside the res://android/build/assets directory of the gradle project. This is done by the already existing export_project_files method, which takes in two function pointers as part of its argument a. The first function pointer points to rename_and_store_file_in_gradle_project which renames a file and stores it in a gradle project b. The second function pointer points to ignore_so_file. This is because all the .so files are copied from the AAR files already.

  5. After these modifications to the res://android directory, the gradle commands to build the app remain unchanged.

The benefit to this method is that by using this new method, a fully fledged gradle project exists for the developer to use. This is different from the original “Use Custom Build” process because that process did not give the developer a useful gradle project to work with, instead it just provided a base gradle project, and the exporting script would still have to build that apk, unzip it, and insert assets and such to this unzipped apk to create the final game apk.

If this enhancement will not be used often, can it be worked around with a few lines of script?: This enhancement will end up being used by everyone who publishes a Godot game to the Google Play Store. The Google Play store will stop accepting APKs and only accept Android App Bundles starting some time in 2021. The only way to build Android App Bundles is by modifying the exporting script inside the Godot engine. There are no simple lines of script that can solve this problem, because the current build system does not use Gradle as the primary build tool.

Is there a reason why this should be core and not an add-on in the asset library?: Being able to export Godot games for Android is a core feature of the Godot editor/engine.

How will this PR be broken down into reasonable, smaller PR’s?

  1. Adding store_file_in_gradle_project, store_so_file_in_gradle_project and rename_and_store_file_in_gradle_project methods. These are all methods related to storing files in the gradle project.

  2. Refactoring of permissions into the _get_permissions method. This refactoring is only related to handling permissions for Android Apps.

  3. Creating the _resize_launcher_icon and _copy_icons_to_gradle_project methods, which are used to copy launcher icons to the gradle project

  4. Adding the _copy_value_xml_files method, which is used to copy the values.xml files into the gradle project.

  5. Adding the _fix_manifest_plaintext method, which is used to fix the Android Manifest file.

  6. Refactoring the gradle_build method, which ties everything else together.

m4gr3d commented 4 years ago

Closing this proposal as a duplicate of https://github.com/godotengine/godot-proposals/issues/1111. The feature is targeted for Godot v3.2.4.

andy-noisyduck commented 4 years ago

Closing this proposal as a duplicate of #1111.

@m4gr3d #1111 was already closed as a duplicate of this one. Which proposal should be referenced for merges?

m4gr3d commented 4 years ago

@andy-noisyduck Thanks for bringing this up, I think I got the two confused :).

That said, the feature has already been merged in and should be released with Godot v3.2.4. Are there additional reasons for keeping this proposal open?

andy-noisyduck commented 4 years ago

@andy-noisyduck Thanks for bringing this up, I think I got the two confused :).

That said, the feature has already been merged in and should be released with Godot v3.2.4. Are there additional reasons for keeping this proposal open?

I was tracking the ticket too and I got a little confused. If its all merged then being closed now is fine.

alexzheng commented 3 years ago

in 3.2.4 beta4, when set export format to aab and click the Android icon to run the project, it always alert "Invalid filename! Android App Bundle requires the *.aab extension."

m4gr3d commented 3 years ago

in 3.2.4 beta4, when set export format to aab and click the Android icon to run the project, it always alert "Invalid filename! Android App Bundle requires the *.aab extension."

@alexzheng can you open a new issue for it.