+4 votes

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 :)

in Engine by (366 points)

2 Answers

+3 votes

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 https://github.com/godotengine/godot/issues/25060#issuecomment-455707658 and links in there.

by (68 points)

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

+5 votes

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.

by (10,918 points)

See also Godot Size Benchmarks for some comparisons :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.