Android App Patch Update

Source: Internet
Author: User

The last week is busy, busy, written 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 we've been studying for the next few days today.

Mobile Internet is the main focus of user experience and product rapid iteration, through user feedback and user behavior tracking timely adjustment product direction, so as to maintain vitality and creativity. Said the grounding gas point is that you frequently upgrade updates, sometimes just fixed a few bugs or fine-tuning the next interface, let users download 10 trillion or even larger apk, and in the current domestic 4G is not popular at the time, the user is very unfriendly. There is no such a strategy, like the Windows system patching, through a small volume of patches to improve the existence of the system bugs or the implementation of new features, if it can be achieved, the user will not be bitter face to update the app. The answer is yes, the following two steps are required to achieve this function.

One, compared to the new version and the old version of the difference, it is best to download only the difference between the parts

The idea is simple and very clear, so 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, the others have to be checked by the Anti-compilation tool. So we apply the install file apk is a binary file, how to get two binary files of the difference file---difference package it? 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. With Bsdiff, we'll be able to get two apk differential packages, and I'll pack the order files into the code and upload it to GitHub for everyone. Bsdiff provides us with only a set of code implemented in C, need to build their own, I have prepared for everyone windows, OSX, Linux different platforms used under the command.

Since my computer is a MacBook, the following commands are executed

After executing the command, we get Xx.patch, which is the difference package that we want to download below. Depending on the difference between different versions, the difference package will be much smaller than the entire apk. Also, if you have multiple versions of your app, you'll need to generate multiple diff packages. If you want to generate the process automation, look for the back-end buddies with easy to solve.

Second, the mobile phone local Download the difference package, and the old version of the apk to merge, and finally merged into the new version of the APK.

Depending on the current version number, a request is made to the server to be downloaded to the corresponding diff package. Here is the old version of the apk and patch merge step, because Java itself does not provide the corresponding API, we need C to help implement, and then generate the. So package to make the call. Another bspatch is provided in relation to the Bsdiff that generates the diff package, which is to help us with the file peace. If you want to implement this step in Android, you need to configure the NDK development environment, if you do not want the students can directly put in the demo file. The following method is called to merge the files

The combined APK file is no different from the latest installation package and has the same characteristic value. Finally, the installation is done via intent.

Written in the end: it is possible that some users are using the version of the older, and the latest apk is very large, it is recommended that the size of the difference package to determine whether to go directly to download the APK to update. At the same time, according to different versions of the difference package, and the back-end of the small partners to automate the generation of words, greatly reducing the generation of differential packet waste time. Finally, if you just fix the key bugs or add a few new requirements, the resulting difference package will be small, and will greatly reduce the user's download time and traffic consumption.

Source Address: Https://github.com/JackCho/AndroidPatchUpdate

If you find it helpful, you are welcome to subscribe to my public account-Android dry Sharing (Id:android_share). Below is the QR code, to provide you with timely high-quality Android dry.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.