How to compress an .APK file say by Winrar(.rar) and then convert it back to .APK?

若如初见. 提交于 2019-12-24 22:25:06

问题


As you all know a disadvantage of Xamarin Forms apps is their huge size. Though I went through different scenarios for reducing app size such as Linking and using Proguard, my Android APK size is still so high(about 30 MB). The thing is when I compressed this apk by Winrar the size got to about 11 MB. I renamed this compressed .rar file to .apk file but when I tried to install this file I got the message: "There was a problem parsing the package".

So my question is is there any mechanism to leverage the compression of a tool like winrar for an APK file so that it could be installed on any Android device?


回答1:


Unfortunately, this isn't that easy. During the packaging process, your app archive will be hashed. If you rar it or do any other tampering with the archive, the resulting app archive will have a different hash than the one it was built with. This will result in your apk invalidating itself on install due to security reasons.




回答2:


You are going to have to unpack it then on the device again. You can't just go and rename a file and expect it to work, the binary structure is completely different.

You will need the user to download an app that is capable of unpacking a .rar (or whatever format you decide on) and learn the user to extract the APK file from there and then install it. The you do need to take into account is that the user needs to be a bit tech savvy to be able to do this and in some cases might even need more rights on a device than is usual. As far as I know there is no delivery mechanism that does this for you.

If you ask me, 30 MB isn't that much and the trouble to go through all this isn't worth the few megabytes you shaved off. If you look at the average apps in the store they are easily bigger than that.



来源:https://stackoverflow.com/questions/50111983/how-to-compress-an-apk-file-say-by-winrar-rar-and-then-convert-it-back-to-ap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!