Hi,
I've been playing a bit with compiling Godot to optimize apk size for simple game like mine:
https://play.google.com/store/apps/details?id=it.megasoft78.fallingword
My current result is 6.5 MB for the complete game apk and 5.3 MB for the template.
This template include the following modules:
Here's are the optimizations I did:
in platform/android/detect.py changed -O2 to -Os and add -s:
env.Append(LINKFLAGS=['-Os', '-s']) env.Append(CPPFLAGS=['-Os', '-DNDEBUG', '-ffast-math', '-funsafe-math-optimizations', '-fomit-frame-pointer'])
I run the compilation with the following options:
scons -j6 platform=android --config=force target=release tools=no deprecated=no minizip=no xml=no builtin_glew=no builtin_libmpcdec=no disable_3d=yes disable_advanced_gui=yes builtin_openssl=no module_openssl_enabled=no builtin_libogg=no builtin_libtheora=no builtin_libvorbis=no builtin_opus=no builtin_speex=no builtin_squish=no builtin_zlib=no module_chibi_enabled=no module_cscript_enabled=no module_dds_enabled=no module_etc1_enabled=no module_gridmap_enabled=no module_ik_enabled=no module_jpg_enabled=no module_mpc_enabled=no module_ogg_enabled=no module_opus_enabled=no module_pbm_enabled=no module_pvr_enabled=no module_speex_enabled=no module_squish_enabled=no module_theora_enabled=no module_vorbis_enabled=no
I disabled all the modules I don't need.
I also comment out in scene/register_scene_types.cpp all the calls to ObjectTypeDB::register_type that I don't need in my game.
My template is arm only because most of the x86 devices on Android support arm emulation and anyway are a very small percentage.
In my game I also used under Project Export Settings on tab Images WebP and on tab Samples IMA-ADPCM.
I was looking to remove physics because I don't use it but it wasn't easy and I give up. :)
The final libgodot_android.so is 8.5MB uncompressed and 3.2Mb compressed in apk.
My assets are 2.5MB uncompressed and 1.1MB compressed in apk.
The classes.dex is 5MB uncompressed and 1.9MB compressed in apk (most of the size is Google Play Services for Admob)
I'm quite happy with the final result and I hope this informations can be useful to other people. :)
If you have any idea to improve even futher just let me know.
Thanks for sharing your experience :)
@Shin-NiL Thank you for your amazing modules! :)
I was able to improve it a little bit more using Proguard.
I'm actually at 4.1 MB for the template and 5.3 MB for my final game.
I'm using the following Proguard:
https://pastebin.com/hM9vJsDV
I'm still testing it to be sure that everything is working but it seems to work.
Now libgodot_android.so is 7.2MB uncompressed and 2.8MB compressed. :)
Hi @megasoft, could we get a link to your appbrain module. I am about to do the same thing. Felt if you've already done it, no need to reinvent the wheel.
However, if you can't provide it, I will just do it with their new mediation platform and stick it in GitHub for others. Cheers.
Hi,I attached the module but I think you need to tweak it to make it work. It was working on Godot 2.1.5. :)
Cheers
Il venerdì 31 agosto 2018, 10:34:00 CEST, Benjamin Yakubu notifications@github.com ha scritto:
Hi @megasoft, could we get a link to your appbrain module. I am about to do the same thing. Felt if you've already done it, no need to reinvent the wheel.
However, if you can't provide it, I will just do it with their new mediation platform and stick it in GitHub for others. Cheers.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Hi,
I attached the module but I think you need to tweak it to make it work. It was working on Godot 2.1.5. :)
Cheers
appbrain.zip
Thanks @megasoft. Cheers
wow, just did this my executable went from 40mb to 20... thank you!!
This could go on the documentation section about optimizations for size
http://docs.godotengine.org/es/latest/development/compiling/optimizing_for_size.html
I get this error at image. https://imgur.com/a/mPIP6lM
How Fix that
It looks like vorbis module is required in your case. Remove the builtin_libvorbis=no and module_vorbis_enabled=no from the command line. :)
It looks like vorbis module is required in your case. Remove the builtin_libvorbis=no and module_vorbis_enabled=no from the command line. :)
Ok. i'll. try
this should pinned or put in the documentation.
Thank you
@mani144 I just opened a pull request to document APK architecture optimization (see above), which is an important step many people forget :slightly_smiling_face:
As for other optimizations, I wonder if they could be integrated directly in Godot somehow. ProGuard in particular could be integrated into the current Gradle setup, including the one that's used for the custom Android build template.
we could suggest scons module details and what is optional for android and ios exporting
hi @megasoft78 , can you pleases share with us your commented register_scene_types file?
you are amazing :) thank you very much for this fastest answer what I ever
have got and for sharing your approach in compiling godot. It was hell for
me last 3 days and your article at github was like light in this darkness
:D now i have 16MB apk and maybe get smaller after succesfull change of
register types file.
thank you very much ;)
pi 15. 11. 2019 o 11:24 megasoft78 notifications@github.com napÃsal(a):
I attached my register_scene_types.cpp.
I hope it help. ;)
register_scene_types.zip
https://github.com/godotengine/godot/files/3850999/register_scene_types.zip—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/godotengine/godot/issues/18253?email_source=notifications&email_token=AI3PCLGRDYVUXU7X6TDFXIDQTZ2HDA5CNFSM4E3BOXCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEFAASY#issuecomment-554303563,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AI3PCLAX5RTLWQMRCGKGASDQTZ2HDANCNFSM4E3BOXCA
.
Don't worry! I know how you feel. Keep going! You'll get there! ;)
I am noob in godot can say where to run that command
@Vignesh1-art Are you talking about scons
command? In your Command Prompt / Terminal.
Most helpful comment
This could go on the documentation section about optimizations for size
http://docs.godotengine.org/es/latest/development/compiling/optimizing_for_size.html