Reducing APK size by re-zipping its content

前端 未结 2 1755
轻奢々
轻奢々 2021-02-20 17:49

I have a pretty large apk file, and I\'m trying to reduce its size. Already used all the common techniques, such as Proguard and image compression. Still, the apk is quite larg

2条回答
  •  感情败类
    2021-02-20 18:52

    I'm able to upload it to Play, install and run it without an issue.

    Only on the devices that you tried. I suspect, for example, that you did not try an API Level 1 device.

    Is there any data that wiped during unzip & rezip process?

    We have no way of answering that question. The only person who can answer that question is you, as you are the one who did your specific "unzip & rezip process". You should be able to analyze your two ZIP files and see where the differences are, such as higher compression ratios on certain file types, files that got lost by the way you ran your "rezip process", etc.

    In general, the only thing that should be lost would be any zipalign-ing, if you did not reapply that yourself.

    If no, why aapt (the one that Android Studio uses) packages files in so inefficient manner?

    Size is not the only consideration. Speed of access is another, as many things (e.g., resources, assets) are kept in the APK file and read out of there on the fly as needed. Memory consumption for the decompression logic is yet another consideration.

    Android devices, particularly early ones, have many constraints, disk space being but one of them. Even though some of these constraints have been relaxed as hardware has advanced, the build tools are dedicated to backwards compatibility -- you should be able to write an app today that can run on an API Level 1 device, for example. That puts constraints on the tools in terms of how they can change over time.

    What could go wrong if I'll use this method?

    Your app may not work on Android devices, where their runtimes are set up making certain assumptions about the APK ZIP compression algorithms use. Ideally, your app will run fine everywhere. At minimum, you would want to test your app on every API level that you support -- older API levels may be somewhat more likely to "cut corners" and make assumptions that your approach will invalidate.

提交回复
热议问题