Skip to content

.so files in the armv8-Apks are not compressed #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hanseul1795 opened this issue Sep 13, 2019 · 3 comments
Closed

.so files in the armv8-Apks are not compressed #118

hanseul1795 opened this issue Sep 13, 2019 · 3 comments

Comments

@hanseul1795
Copy link

hanseul1795 commented Sep 13, 2019

Describe the bug
I'm creating the .Apks files from the .Aab, for all available architectures.
1- armv7-apks is compressed and have normal size ~25 MB
2- armv8-apks is not compressed and have ~75 MB.

Bundletool version(s) affected
Version: [0.10.1]

To Reproduce
Steps to reproduce the behavior.
Generate the .Aab file with Xamarin Android and create the .Apks file for armv8.

Expected behavior
the result file should be compressed.

Environment:
OS: [Android 8.0]

@brendanzagaeski
Copy link

The bundletool team can correct me if I'm mistaken, but I believe you are seeing the correct expected behavior for bundletool. When deploying to a particular device, bundletool determines whether or not to compress the native libraries in the APK based on the app install location and the version of Android OS on the target device:

https://github.com/google/bundletool/blob/0.10.1/src/main/java/com/android/tools/build/bundletool/splitters/NativeLibrariesCompressionSplitter.java#L75-L86

In case it helps to think about the value of shouldCompress in the other direction, it means that when deploying to an Android 9.0 Pie (API level 28) or higher device, bundletool will always leave the native libraries uncompressed in the APK. When deploying to a device running an Android version between 6.0 Marshmallow (API level 23) and 8.1 Oreo (API level 27), bundletool will only leave the native libraries uncompressed in the APK if the app is not installable on external storage (for example, if the android:installLocation <manifest> element attribute is set to "internalOnly").

The reason to have uncompressed native libraries in the APK is that Android 6.0 Marshmallow and higher can read uncompressed native libraries directly from the APK instead of extracting them to the file system. See also the android:extractNativeLibs <application> element attribute.

@plecesne
Copy link
Contributor

plecesne commented Sep 14, 2019

That is correct, thanks Brendan.

Leaving the native libraries uncompressed provides the following benefits:

  • Space savings on the device (as explained by Brendan), since the Android platform doesn't have to extract the library out of the APK at installation time, it will directly mmap it in memory.
  • Size savings on download, since the compression that is performed over the wire of the APK when sent to a device is more effective when the data it compresses is not already compressed.

@trungnd90
Copy link

Hi, @plecesne do you know how to force compress native libraries in apk?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants