All Products
Search
Document Center

Mobile Platform as a Service:Add obfuscation rules

Last Updated:Jul 26, 2023

Apps developed on mPaaS Android clients are compiled using Java codes which may easily be decompiled. Therefore, we need to use Android ProGuard obfuscation files to protect Java source codes. This topic describes the process to add obfuscation rules in native AAR access mode.

Procedure

  1. Customize yw_1222.jpg as the resource to keep. Create an XML file in your project that contains the <resources> tag and specify yw_1222.jpg as the resource to keep in the tools:keep attribute. If desired, each resource to be discarded can also be specified in the tools:discard attribute. Both properties accept a comma-separated list of resource names. The asterisk (*) character can be used as a wildcard.

    <?xml version="1.0" encoding="utf-8"?>
    <resources xmlns:tools="http://schemas.android.com/tools"
     tools:keep="@drawable/yw_1222"/>
    39
  2. Execute the task to generate an obfuscated file. Click on mPDebugProguardTask (or mPReleaseProguardTask).

    40
  3. After the execution, obfuscation files will be added to the project, as shown in the following figure.

    41
  4. Append the generated obfuscation files to the obfuscation policy.

    41
    Note

    If transformClassesAndResourcesWithR8ForRelease is frozen during obfuscation, we recommend that you disable R8 and then perform obfuscation again. To disable R8:

    Add android.enableR8=false in gradle.properties.

    42