All Products
Search
Document Center

Quick start

Last Updated: Nov 30, 2021

This topic briefly describes how to fast integrate the Hotpatch function to the current App. Currently, you can access Hotpatch through Native AAR, mPaaS Inside, or Portal & Bundle.

The complete access process mainly includes the following 5 steps:

  1. Add SDK

  2. Initialize Hotpatch (only required for Native AAR and mPaaS Inside)

  3. Generate hotpatch packages

  4. Release hotpatch packages

  5. Trigger hotpatch

Prerequisites

Add SDK

Native AAR mode

Follow the instructions in AAR component management to install the HOTFIX component in the project through Component management (AAR).

mPaaS Inside mode

Install the HOTFIX component in the project through Component management (AAR).

For more information, see Manage component dependencies > Add/delete component dependencies.

Componentized access mode

Install the HOTFIX component in the Portal and Bundle projects through Component management (AAR).

For more information, see Manage component dependencies > Add/delete component dependencies.

Initialize Hotpatch

Native AAR/mPaaS Inside

To use the Hotpatch function, you must complete the following two steps:

  1. Inherit the Application object as QuinoxlessApplicationLike, and set anti-aliasing for the class. See “MyApplication” for example.

      @Keep
      public class MyApplication extends QuinoxlessApplicationLike implements Application.ActivityLifecycleCallbacks {
       private static final String TAG = "MyApplication";
       @Override
       protected void attachBaseContext(Context base) {
           super.attachBaseContext(base);
           Log.i(TAG, "attacheBaseContext");
       }
       @Override
       public void onCreate() {
           super.onCreate();
           Log.i(TAG, "onCreate");
           registerActivityLifecycleCallbacks(this);
       }
       @Override
       public void onMPaaSFrameworkInitFinished() {
          MPHotpatch.init(); 
           LoggerFactory.getTraceLogger().info(TAG, getProcessName());
       }
       @Override
       public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
           Log.i(TAG, "onActivityCreated");
       }
       @Override
       public void onActivityStarted(Activity activity) {
       }
       @Override
       public void onActivityResumed(Activity activity) {
       }
       @Override
       public void onActivityPaused(Activity activity) {
       }
       @Override
       public void onActivityStopped(Activity activity) {
       }
       @Override
       public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
       }
       @Override
       public void onActivityDestroyed(Activity activity) {
       }
      }
  2. In the AndroidManifest.xml file, point the Application object to the Application object provided by mPaaS. Add the newly generated “MyApplication” class to the “meta-data” key with the key “mpaas.quinoxless.extern.application”. For example:

     <application
         android:name="com.alipay.mobile.framework.quinoxless.QuinoxlessApplication" >
         <meta-data
              android:name="mpaas.quinoxless.extern.application"
              android:value="com.mpaas.demo.MyApplication" 
              />
     </application>

    com.mpaas.demo.MyApplication refers to the Application proxy class you customized, which inherits QuinoxlessApplicationLike.

Componentized access mode

In this access mode, you don’t have to make any change.

Generate hotpatch packages

See Generate hotpatch packages.

Release hotpatch packages

See Release hotpatch packages.

Trigger hotpatch

This section describes the hotpatch process in detail with DynamicRelease demo which can be downloaded from the Code samples.

In the code sample, what to be fixed is the content in a pop-up toast.

  1. Before fixing Click the Simulate the click event to be fixed button, the toast Exception, current click event not hot fixed pops up.

  2. Fix the bug Click the Trigger hotpatch detection button to download the hotpatch package. When the hotpatch package is downloaded, completely close the Demo application and restart it.

  3. After fixingClick the Simulate the click event to be fixed button, and the toast Current click event hot fixed pops up.

Troubleshooting

Note:
  • Do not introduce apache-httpclient in an informal way, refer to Android Application Developer Platform Official Documents.

  • Don’t introduce SDKs related to NFC systems in an informal way.

  • Make sure that you haven’t inherited any Application-related classes, and use ApplicationLike instead.

Use the tag DynamicRelease to filter hotpatch logs.

  • Download stage: RPCException can be filtered at the same time. If there are related exceptions, the download will not succeed.

  • Patch mergence stage: Filter the logs with the condition immediately=true. If relevant logs are found, it means that the patch was merged successfully. After the patch is successfully merged, in theory, the patch will take effect as long as the App is restarted.