Last week busier than busy, busy, writing articles are two, in this hope we forgive. This week, suddenly idle down, there is time, on the reconstruction of the code, beat the drum avantgarde technology, precipitate precipitation. So. Share what you've studied for the next few days today.
Mobile Internet is the main focus of user experience and product high-speed iteration, through user feedback and user behavior tracking timely adjustment product direction, so talent continue to maintain vitality and creativity. Say the grounding gas point is that you frequently upgrade updates. Sometimes just fix a few bugs or fine-tune the next interface, let users download 10 trillion or even larger apk, and in the current domestic 4G is not universal. is very unfriendly to the user.
Is there a strategy like patching on Windows systems? The implementation of a bug or new feature of a system that is well-documented by a smaller patch is assumed to be achievable. Users will not be bitter face to update the app. The answer is yes. To implement this function. The following two steps are required.
One, the difference between the new version number and the old version number, it is best to download only the difference part
The idea is very easy. is also very clear, then we will follow this goal. The APK itself is actually a zip compression package, you change the suffix name, and then double-click Unzip to get the APK inside the compiled package file, picture audio and other files are directly readable, and others have to be checked through the Anti-compilation tool. So the installation file that we applied is a binary file. How do I get the difference file for two binary files---difference package? The good news is that there have been previous implementations. Its name Bsdiff, a diff package comparison tool, full name is binary diff, binary difference meaning. Through Bsdiff. We will be able to get the two apk difference package, the following I will pack the command file into the code upload github for everyone to use. Bsdiff provides us with only a set of code implemented in C, it is necessary to build their own, I have prepared the Windows, OSX, Linux different platforms used under the command.
Because my computer is a MacBook. Run commands such as the following
After the command is run. Get Xx.patch, we want to download the following is the difference package. Depending on the difference between the different version numbers. The size of the diff package will be much smaller than the entire apk. At the same time, if you have multiple versions of your app's old version number, you'll need to generate the appropriate number of diff packages.
Let's say that the process you want to generate is self-motivated. Find the backstage buddies with easy to solve.
Second, the mobile phone local Download the difference package, and then the old version number apk to merge. Finally merge into the new version number APK.
The request is initiated to the server based on the current version number, and it is downloaded to the appropriate diff package. Here is a step for the old version number apk and patch merge, because Java itself does not provide the appropriate API. We need c to help implement, and then generate the. So package to make the call.
Relative to the Bsdiff that generated the diff package. Also provides a bspatch, this is to help us carry out the document peace.
Suppose you want to do this in Android. It is necessary to configure the NDK development environment, assuming that the students do not want to be able to directly use the. so file in the demo.
It is possible to merge files by calling this method:
The combined APK file is no different from the latest installation package and has the same eigenvalues.
Finally, the installation is done via intent.
Written in the end: it is possible that some users use the version number is older, and the latest apk is very large, or it is recommended that the size of the difference package to determine whether to directly download the APK to update. At the same time, according to different version number corresponding to the difference package, and the back-end of the small partners to their own initiative to generate, greatly reducing the generation of differences in packet time wasted.
The final hypothesis is to fix critical bugs or add a few new requirements, resulting in a very small variance package, which greatly reduces the user's download time and traffic consumption.
Source code Address: Https://github.com/JackCho/AndroidPatchUpdate
If you think it's helpful, you're welcome to subscribe to my public account-Android dry Sharing (Id:android_share). The following is the QR code, to provide you with timely high-quality Android dry. Technical Exchange QQ Group: 318588906, welcome everyone to add a group, together to explore the next Android and Java technology, together to expand our dry sharing community.
Android App Patch Update