Android-app the use posture of incremental updates _android

Source: Internet
Author: User
Tags md5

Briefly

Incremental update, literally, is to download the added part to achieve the purpose of the update, which is actually the meaning.

Principle

With an old APK installation and a new APK installation package using the Bsdiff tool, execute the command to generate a differential file, which is the part of the change we need to update the download.

Introducing code and so files

First, depending on the architecture of your system, choose a different so file to put in your project.

Then, you need to introduce Java classes that load the so file into your project, and when introduced, you should be aware that you cannot modify the package name of this class.

To this end, the incremental update is introduced.

Use

Download the Bsdiff tool, and then execute the command: Bsdiff, display a command prompt

Then, execute the correct command, and the result is as follows:

Command: Bsdiff app_1.1.apk app_1.2.apk Patch.patch
Parameters:
app_1.1: Old published version
app_1.2: New Releases not released
Patch.patch: Generated differential file

This patch file can be placed on the server for version 1.1 users to download and incrementally update the upgrade.

Client Incremental Update Interface:

public native static int Bspatch (string oldapkpath,          
string Newapkpath, String patchpath);          
Oldapkpath: Current apk directory          
//newapkpath: Generate new apk to store directory          
//patchpath: directory where the difference files reside

Warm tip: Remember to add network and file read and write permissions

<uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/> 
 <uses-permission Android:name= "Android.permission.READ_EXTERNAL_STORAGE"/> 
 <uses-permission android:name= " Android.permission.INTERNET "/>

Gets the APK directory code for the current application:

Context.getapplicationinfo (). SourceDir;

The actual development process uploads the new APK installation package to the server, allowing the server to generate a different version of the differential file. The server needs to provide an interface, the version of your current app passed through the interface to the server, the server resolved to determine, after the response data to tell the client whether the need to download the difference file, because different versions of the different download differences file, here need to pay attention. If the data returned by the interface tells the client that there is a differential file download, the client uses the child thread download, then performs the incremental update of the merge interface, and then generates the new APK installation package, which completes the incremental update process.

Effect

First install the app_1.1.apk version of the installation package to the phone, this package is equivalent to your published online version 1.1.

Then put the difference file into the SDcard (easy to test to put into the sdcard directly)

Then click the Patch button and then jump to the installation interface when the merge is complete

Confirm installation, installation complete, click to enter application

To this end, android-incremental update of the use and effect of the display has been completed, there are questions can be a direct message.

Check whether the synthesized apk is complete

For now, I think of 2 ways to verify the completion of a new APK file that is merged with a differential file:

Gets the signature of the old APK installation package and the signature that has been merged into the new APK installation package, compare signatures If you download the difference file, you can let the server give you back the new APK merged successfully after the file MD5, when you successfully merged, by verifying the MD5 value of the file, to verify the integrity of the file.

The inadequacy of the place假设,当你的app已经发布了1.1、2.1、3.1等等版本的时候,现在你有要更新版本到4.1,当然增量更新可以帮你做到,但是存在不足之处。

You need to upload the new 4.1 app package to the server, and the server needs to compare with all published versions to produce the same version of the difference file, of course, if some version is no longer maintained can not be generated.

Related Article

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.