Reputation: 4349
I am working for migrating to LibC++ from Gnustl and I am observing an overall 8-10% Increase in size after migrating to LibC++ from gnustl in Android. Few additional dependencies that we have added that could account for the size is,
• Statically linking additional libunwind.a from libc++ in each so.
• Overriding typeInfo class, especially due to the difference in the behavior of checking typeInfo == operator.
But even after these two changes, I don't understand what has accounted for overall size increase. I initially suspected somehow introduction of LibC++ is disabling the debug symbols stripping but that's also not true, I have verified by explicitly disabling the -Wl,--gc-sections & -ffunction-sections -fdata-sections, which further increases the size of the generated SO and APKs.
Since many of others have already gone through this cycle, I thought it would be good to ask whether or not, others have also observed these side effects of increasing size when using LibC++?
Thanks/
Upvotes: 0
Views: 102
Reputation: 3594
My suggestion is to Analyze your APK with Android Studio's analyzing tool: To do so, in Android Studio just go to Build -> Analyze APK -> Select any built APK file, and finally watch the size of every file contained in your APK:
Then compare it with an APK using Gnustl
Usually what most increase APK size are native .so files. Probably libc++'s native files are bigger than Gnustl's. Or what is even more probably libg++ adds .so files for some CPU architectures Gnustl doesn't. I mean, more directories could appear inside lib directory.
If the second is your case you could use Android App Bundle when publishing your APK on Google Play to ensure devices just download their most apropiate .so files and not the others. What reduces consideratebly the total size of the installed app.
Upvotes: 0