Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android App Bundle Support - PR #39761 #1111

Closed
amanj120 opened this issue Jun 23, 2020 · 2 comments
Closed

Android App Bundle Support - PR #39761 #1111

amanj120 opened this issue Jun 23, 2020 · 2 comments

Comments

@amanj120
Copy link

amanj120 commented Jun 23, 2020

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.

PR 39761 has the changes

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 check to make sure the export path of the apk is valid, and then it will call _update_custom_build_project to overwrite the build.gradle file inside the res://android/build directory

  3. 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)

  4. The exporting script will look through the godot-lib.debug.aar and godot-lib.release.aar to copy all the values.xml files over to res://android/build/res/values directories. While it’s copying files, it will fix the project name by altering the text of these values.xml files. This all happens in the _copy_value_xml_files method.

  5. The exporting script will alter the Android Manifest file. There will be a base Manifest file that will be modified by replacing some placeholder strings. The placeholder strings look like *PLACEHOLDER_VALUE*. The newly generated manifest file is written into the gradle project.

  6. 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 store_so_file_in_gradle_project which stores the libgodot_android.so and libc++_shared.so files in the gradle project

  7. 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.

@IoneGod
Copy link

IoneGod commented Jun 23, 2020

This problem has been mentioned a in #342 you can check out the details

@Calinou
Copy link
Member

Calinou commented Jun 23, 2020

Duplicate of #342. I suggest posting your proposal as a comment in that issue, as it seems to have some new information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants