APK size decrease after gradle plugin update to version 3.6

97 views
Skip to first unread message

s_petr...@wgmobile.net

unread,
Oct 16, 2020, 6:28:03 PM10/16/20
to android-ndk
Good day!
Can someone explain me the reason of apk size decrease after gradle plugin update to version 3.6?
I use NDK and c++ src in my project. After update I realized that apk has smaller size (100mb vs 150mb). I explored APK and found that myapp.so (in lib/armeabi-v7a/ ) has size 10mb instead of 20mb. I revert plugin update and rebuild the app. myapp.so size went back to 20mb. I did read Release Notes but didn't find any reason. I read about android:extractNativeLibs parameter, it set explicitly to true in manifest.xml in both builds. But size still differs. So the only thing that I change is the plugin's version (from 3.5.4 to 3.6.0). 
APK size reduction is okay for me, but I am very interested how it happens and why.

Any help is appreciated
Thanks

yu...@unity3d.com

unread,
Oct 19, 2020, 10:57:17 AM10/19/20
to android-ndk
Hey!

extractNativeLibs should affect the size of the APK, but not the size of the .so itself in the APK.
I guess the NDK version is the same in both cases, isn't it?

I can't tell you the exact reason on what's happening, but you could check on your own using objdump and checking if there's some obvious difference, like - missing section (debug info? symbols?).

Cheers
Yury

Alex Cohn

unread,
Oct 28, 2020, 6:36:36 AM10/28/20
to android-ndk
Most likely, your shared object is called libmyapp.so. This "lib" prefix is essential for the package manager to locate and install your libraries correctly.

Anyways, the change of file size after upgrading the AGP may be attributed to the build stage when the native libraries are stripped (removing some debug information), which could easily account for a 50% decrease. This strip is performed by the NDK, which must be installed on the build machine even if the APK uses prebuilt libraries. Also, each version of AGP expects a specific version of NDK, and if there is no match, the strip step may be simply skipped. 

BR,
Alex
Reply all
Reply to author
Forward
0 new messages