Amigo

Before fix: Click text no jump

Fixed: Click on text to jump (Activity and layout file added)

In fact, the most important thing about hot update is that you don’t need to reinstall APK, and some even don’t need to restart app, you can update code or resource files.

I have compared several mainstream hot update schemes, and feel Amigo is the most suitable one for me at present.

Compare the item Amigo Tinker nuwa/QZone AndFix Dexposed
Class to replace yes yes yes no no
Lib to replace yes yes no no no
Resources to replace yes yes yes no no
Full platform support yes yes yes yes no
Effective immediately optional no no yes yes
Performance loss There is no smaller larger smaller smaller
Patch pack size larger smaller larger general general
The development of transparent yes yes yes no no
The complexity of the There is no The lower The lower complex complex
Gradle support yes yes yes no no
Interface documentation rich rich general general less
Volume of Rom larger larger smaller smaller smaller
The success rate 100% good high general general

The above table is from the Github homepage of Amigo. I think the success rate of 100% has played a good publicity effect!

Tinker is so powerful that it can replace almost everything except the Androidmanifest.xml file and a few tinker classes, including layout and resources. The downside is that its first configuration is a bit more complicated, making it a bit more difficult to get started than AndFix.

AndFix cannot fix onCreate() of Application, and it has been upgraded to SopHix, which needs to use Ali’s platform and is free at 50,000 units per month. It looks like SopHix is powerful, but to plug into Ali…

Robust is the program of Meituan, but due to code intrusion, operation efficiency, method number and package volume are affected. As the number of file methods increases, the enterprise application may involve problems of 65535.

Amigo is to download a complete APK (so the package is a bit large, of course, can also do the difference subcontracting), support to add activities, support to modify resource files.

The key is easy access.

In the build.gradle of project:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com. Android. Tools. Build: gradle: 2.3.0'. classpath'me. Ele: amigo: 0.6.8'}}Copy the code

By the way, currently Amigo does not support gradle3.0, I am using 2.3.0.

In the module of the build. Gradle

apply plugin: 'me.ele.amigo'

android {
...
}

dependencies {
    ...
    compile 'me. Ele: amigo - lib: 0.6.7'
}

//if you don't want use amigo in dev, set this value to true
//you can define this extension in your mybuild.gradle as to distinguish debug & release build
amigo {
    disable false //default false
    autoDisableInInstantRunMode true // default false
}
Copy the code

Call update (the new APK is already local)

var file = File(Environment.getExternalStorageDirectory().path + File.separator + "test.apk")
            if(file.exists()){
                Amigo.workLater(this, file) {
                    if(it){
                        toast("Update successful!")
                        val intent = packageManager.getLaunchIntentForPackage(packageName)
                        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
                        startActivity(intent)
                        android.os.Process.killProcess(android.os.Process.myPid())
                    }
                }
            }
Copy the code

Finally, restart the App.

I call Amigo. Work (context, patchApkFile); Method The APP will not restart automatically, you need to manually click the icon to start.

In Amigo plug-ins, replace the original Application, so Amigo supports modifying the Application.

Amigo replaces the entire dex file, so the success rate is guaranteed.