• Building
  • Optimize the size of the apk for Google Play Store

Hello,

I want to put my apk on the play store but I have a warning on google play console that indicates the apk is not optimized (because some modules compiled are not used). It's not mandatory but it's a recommandation to have a good visibility.

Following this documentation (https://docs.godotengine.org/en/stable/development/compiling/optimizing_for_size.html) I did a custom template export with this configuration :

custom.py

use_thinlto = "yes"
disable_3d = "yes"
tools = "no"
debug_symbols = "yes"
pulseaudio = "no"
deprecated = "no"
minizip = "no"
module_cvtt_enabled = "no"
module_stb_vorbis_enabled = "no"
debug_symbols = "no"
module_visual_script_enabled = "no"
module_jpg_enabled = "no"
module_ogg_enabled = "no"
disable_advanced_gui = "yes"
module_arkit_enabled = "no"
module_assimp_enabled = "no"
module_bmp_enabled = "no"
module_bullet_enabled = "no"
module_camera_enabled = "no"
module_csg_enabled = "no"
module_dds_enabled = "no"
module_enet_enabled = "no"
module_etc_enabled = "no"
module_gdnative_enabled = "no"
module_gridmap_enabled = "no"
module_hdr_enabled = "no"
module_jsonrpc_enabled = "no"
module_mbedtls_enabled = "no"
module_mobile_vr_enabled = "no"
module_opensimplex_enabled = "no"
module_opus_enabled = "no"
module_pvr_enabled = "no"
module_recast_enabled = "no"
module_regex_enabled = "no"
module_squish_enabled = "no"
module_svg_enabled = "no"
module_tga_enabled = "no"
module_theora_enabled = "no"
module_tinyexr_enabled = "no"
module_upnp_enabled = "no"
module_vhacd_enabled = "no"
module_vorbis_enabled = "no"
module_webm_enabled = "no"
module_webp_enabled = "no"
module_webrtc_enabled = "no"
module_websocket_enabled = "no"
module_xatlas_unwrap_enabled = "no"

I use godot-3.2.2-stable source and the compilation with scons and template generation works well :

scons platform=android target=release
cd platform/android/java
./gradlew generateGodotTemplates

Then I move the bin release apk in the .local/share/godot/templates/3.2.2.stable as explained here (https://docs.godotengine.org/en/stable/development/compiling/compiling_for_android.html).

In the godot editor : - I specify the "Custom build sdk path" in editor menu - I remove folder android in the project app and install a new compilation android build in the project menu. - I specify "Use custom build" in export and set the path of release apk

I export the project, a console starts the gradle daemon, and the release game apk is well generated.

  • With official template my game apk has a size of 96.2 Mo
  • With my custom template my game apk has a size of 84 Mo

But google play console continue indicates that the apk is not optimized.

What are the settings to resolve this warning ?

Thank for your listening !

4 days later

Could someone who has already used custom build models share its feedback ?

3 years later

Asset Compression:

Use image compression tools to reduce the size of images in your app without compromising quality.
Convert images to WebP format, which often provides better compression compared to JPEG or PNG.
Code and Resource Shrinking:

Utilize ProGuard to shrink and obfuscate your code. ProGuard can remove unused classes, methods, and attributes.
Use resource shrinking to remove unused resources from your project.
Remove Unused Resources:

Identify and remove any resources (images, layouts, strings) that are not being used in your app.
Dynamic Delivery:

Use the Android App Bundle format to enable Dynamic Delivery. This allows users to download only the resources they need for their specific device configuration.
Split APKs:

Break your APK into multiple APKs based on device configurations. This way, users download only the components necessary for their device.
Optimize Libraries:

If you're using third-party libraries, ensure that you only include the necessary parts. Some libraries offer slim versions that include only essential components.
Use Vector Drawables:

Replace bitmap images with vector drawables whenever possible. Vector drawables are resolution-independent and can be more space-efficient.
Audio and Video Compression:

Compress audio and video files to reduce their size. Consider using formats with better compression, such as AAC for audio and H.265 for video.
Optimize XML Files:

Minimize the use of unnecessary attributes in XML files, such as layout files. Optimize the structure of your XML files.
Update Dependencies:

Ensure that you are using the latest versions of your development tools and dependencies, as newer versions often include optimizations.
Compress Resources:

Use tools like OptiPNG for PNG images or JPEGoptim for JPEG images to further compress resources.