2

I want to reduce my apk file size. so, i tried to compress the resoruces.arsc file in MyApp.apk file. Because that file is the most reducable file in APK files. I was test few apk files (include other apps), But it pretty well working. Performance when application execute, is also not a different. There are any other issue/causes are exist? Why that file is not compress?

peridot820
  • 21
  • 1
  • 3
  • You can refer to this [SO](https://stackoverflow.com/questions/39826626/how-to-reduce-android-apk-size/49573117#49573117) OR [SO](https://stackoverflow.com/questions/34529504/how-to-reduce-apk-size-when-using-play-services-gcm/49572661#49572661) – Sagar Mar 30 '18 at 11:04

1 Answers1

11

Zip/Jar/APK compression allows individual files within the zip to be left uncompressed. In APKs the resources.arsc file is generally intentionally left uncompressed. This is done so it can be mmappped . The resources.arsc file is read by other processes (to get your app name and icon in the launcher, the recent apps page, any of your notifications, etc), so efficient read speed is important. It appears that the size can be very large if you target minSdkVersion < 7 as strings were stored as UTF-16 then. However if your minSdkVersion is >= 7, it should use UTF-8 which is notably smaller.

See Hackborn's responses at https://groups.google.com/d/msg/android-developers/c4_Wkkby91c/Hyav-zQKz6UJ and https://groups.google.com/d/msg/android-developers/_pM3Ugx_3hw/5EFiPdz92NwJ

Kevin TeslaCoil
  • 10,037
  • 1
  • 39
  • 33
  • The dividing line between UTF-16 & UTF-8 actually lies between API 7 & API 8. (From aapt:`bool useUTF8 = !bundle->getWantUTF16() && bundle->isMinSdkAtLeast(SDK_FROYO);`) – Renate Nov 18 '15 at 01:35
  • 1
    The two links above don't work, with "Banned Content Warning" and "The group you are attempting to view (Android Developers) has been identified as containing spam, malware, or other malicious content. Content in this group is now limited to view-only mode for those with access. Group owners can request an appeal after they have taken steps to clean up potentially offensive content in the forum. For more information about content policies on Google Groups see our Help Center article on abuse and our Terms of Service." – auspicious99 Jan 29 '20 at 10:08
  • 1
    Note that Android 11 now bans the use of a compressed resources.arsc file: https://developer.android.com/preview/behavior-changes-11#compressed-resource-file – Rob Meeuwisse Jul 29 '20 at 09:36