APK size decrease after gradle plugin update to version 3.6

已查看 97 次
跳至第一个未读帖子

s_petr...@wgmobile.net

未读,
2020年10月16日 18:28:032020/10/16
收件人 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

未读,
2020年10月19日 10:57:172020/10/19
收件人 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

未读,
2020年10月28日 06:36:362020/10/28
收件人 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
回复全部
回复作者
转发
0 个新帖子