All Products
Search
Document Center

Quick start

Last Updated: May 08, 2021

This topic briefly describes how to integrate the Hotpatch function to the current Android 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.

       
    1. @Keep
    2. public class MyApplication extends QuinoxlessApplicationLike implements Application.ActivityLifecycleCallbacks {
    3. private static final String TAG = "MyApplication";
    4. @Override
    5. protected void attachBaseContext(Context base) {
    6. super.attachBaseContext(base);
    7. Log.i(TAG, "attacheBaseContext");
    8. }
    9. @Override
    10. public void onCreate() {
    11. super.onCreate();
    12. Log.i(TAG, "onCreate");
    13. registerActivityLifecycleCallbacks(this);
    14. }
    15. @Override
    16. public void onMPaaSFrameworkInitFinished() {
    17. MPHotPatch.init();
    18. LoggerFactory.getTraceLogger().info(TAG, getProcessName());
    19. }
    20. @Override
    21. public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
    22. Log.i(TAG, "onActivityCreated");
    23. }
    24. @Override
    25. public void onActivityStarted(Activity activity) {
    26. }
    27. @Override
    28. public void onActivityResumed(Activity activity) {
    29. }
    30. @Override
    31. public void onActivityPaused(Activity activity) {
    32. }
    33. @Override
    34. public void onActivityStopped(Activity activity) {
    35. }
    36. @Override
    37. public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
    38. }
    39. @Override
    40. public void onActivityDestroyed(Activity activity) {
    41. }
    42. }
  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:

       
    1. <application
    2. android:name="com.alipay.mobile.framework.quinoxless.QuinoxlessApplication" >
    3. <meta-data
    4. android:name="mpaas.quinoxless.extern.application"
    5. android:value="com.mpaas.demo.MyApplication"
    6. />
    7. </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 fixing
    Click 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.
    Note:If RPC exception occurs, you can troubleshoot according to the error code. Refer to Call the RPC API for more information.
  • 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.