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
Customize
yw_1222.jpg
as the resource to keep. Create an XML file in your project that contains the<resources>
tag and specifyyw_1222.jpg
as the resource to keep in the tools:keep attribute. If desired, each resource to be discarded can also be specified in thetools: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"/>
Execute the task to generate an obfuscated file. Click on mPDebugProguardTask (or mPReleaseProguardTask).
After the execution, obfuscation files will be added to the project, as shown in the following figure.
Append the generated obfuscation files to the obfuscation policy.
NoteIf
transformClassesAndResourcesWithR8ForRelease
is frozen during obfuscation, we recommend that you disable R8 and then perform obfuscation again. To disable R8:Add
android.enableR8=false
ingradle.properties
.