How to reduce Android APK size? Reduce startup time too?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By i_love_godot

Ok, so I have been reading this article about APK size optimization, but that doesn’t reduce the APK that much when using export templates that I compile from source VS the default ones. I even tried this optimization method… but I’m not seeing anywhere near the size savings that that person achieved.

Even with a really basic demo project, that doesn’t contain much, I’m barely getting the APK under 20MB. Is this the new normal? Is that just how big the Godot engine is?

The size itself isn’t really a deal breaker, but I do like the idea of only including the modules I need. Would it speed up the app startup time too? Basic apps tested on fairly modern Android devices take several seconds to reach first scene. Presumably because the engine is loading a lot of things I won’t use. Maybe that’s a misguided optimization attempt, I don’t know.

If anyone has compiled their own export templates and has some tips for optimizations, please feel free to share :slight_smile:

:bust_in_silhouette: Reply From: j2l

Default android template is loading a lot of stuff.
You need to recompile android module like this:

scons -j4 android_arch=armv7 platform=android target=release_debug optimize=speed tools=no use_lto=no deprecated=no gdscript=no minizip=no xaudio2=no disable_3d=yes disable_advanced_gui=yes no_editor_splash=yes builtin_bullet=no builtin_certs=no builtin_enet=no builtin_libogg=no builtin_libtheora=no builtin_libvorbis=no builtin_libvpx=no builtin_libwebp=no builtin_libwebsockets=no builtin_mbedtls=no builtin_miniupnpc=no builtin_opus=no builtin_pcre2=no builtin_recast=no builtin_squish=no builtin_thekla_atlas=no builtin_xatlas=no builtin_zlib=no debug_symbols=no separate_debug_symbols=no android_neon=no android_stl=no module_bmp_enabled=no module_bullet_enabled=no module_csg_enabled=no module_cvtt_enabled=no module_dds_enabled=no module_enet_enabled=no module_etc_enabled=no module_gdnative_enabled=no module_gdscript_enabled=no module_gridmap_enabled=no module_hdr_enabled=no module_jpg_enabled=no module_mbedtls_enabled=no module_mobile_vr_enabled=no module_mono_enabled=no module_ogg_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_stb_vorbis_enabled=no module_svg_enabled=no module_tga_enabled=no module_thekla_unwrap_enabled=no module_theora_enabled=no module_tinyexr_enabled=no module_upnp_enabled=no module_visual_script_enabled=no module_vorbis_enabled=no module_webm_enabled=no module_webp_enabled=no module_websocket_enabled=no module_xatlas_unwrap_enabled=no config=force

Where the source is the same as the editor version (!)
For more, see Add a build-time option to disable Google Payments for in-app purchases · Issue #25060 · godotengine/godot · GitHub and links in there.

trying that code breaks a lot of things in my game but I don’t think I’m even using those things.

idkaryan | 2019-11-03 04:21

:bust_in_silhouette: Reply From: Calinou

You should export one APK per architecture supported by Android (ARMv7, ARMv8, x86) then upload them using Google Play’s multiple APK support. x86 is optional, but ARMv7 and ARMv8 (64-bit ARM) will be required starting from August 2019. To do so, create several export presets, each of them having only one architecture checked (the export process will strip unused libraries from the APK).

This will make each APK much smaller as it will only contain the native library required by the user’s device.

See also Godot Size Benchmarks for some comparisons :slight_smile:

Calinou | 2019-04-23 22:37