I've been experimenting with apk size reduction lately and I'd like to share my experiences:
I have developed a quite simple snake clone (source) whose assets take up less than 300 kb of space. As you might already acknowledge, games exported for Android with default export templates usually end up taking lots of space even if they are so minimal in design. Thus, I built my own export templates without any modes or modules I don't need. By this way I managed to reduce the .apk size from ~30 mb to ~7 mb (and the installed app size from ~60 mb to 25-30 mb).
I think this is acceptable for an average game but I wanted to make this one as lightweight as possible, so I started to look for other methods to reduce its size. I tried to follow the steps mentioned in this Github issue when building new templates, but it was very troubling for me:
- My game uses around 10 types of nodes so I tried to comment out all calls to nodes I don't use in scene/register_scene_types.cpp. For some reason, I couldn't observe any difference in the result. Thus, I just decided to erase the files themselves in my next try. It ended up giving lots of errors compiling as you might expect, many source files were referencing to each other. When I finally managed to get it working with all those missing files, it didn't turn out to be very efficient for me anyway: I could only reduce a couple of megabytes at best. I thought it wasn't worth risking the game's core stability so I reverted these changes for the time being.
- I have tried to use ProGuard for further size reduciton but I couldn't get it working either. I have read that code shrinking is configured through the project's build.gradle file so I messed with platform/android/java/build.gradle a few times. It wasn't succesful: sometimes Gradle overwrote my modified file and sometimes produced a non-functional .apk build. Guess I just don't know the right configurations.
- Also, a "compressed size" is mentioned in the Github issue, but I don't know if it would help me further reduce the game's size.
So, I think I will stick to my older reduced template for now. Did anyone else ever try such reductions too? How was the result or how did you manage to get it working? Or, do you know if newer versions of Godot plan to make size reduction easier?
Any feedback is greatly appreciated!