3.1 KiB
title | description | type | page_title | slug | position | tags | teampulseid | ticketid | pitsid |
---|---|---|---|---|---|---|---|---|---|
How to Obfuscate Java Code With ProGuard | Obfuscating the Java Code of an AppBuilder Apache Cordova app | how-to | Java Obfuscation for AppBuilder applications | obfuscate-java-code | obfuscate, cordova, proguard | 1077265 |
Environment
Service | Code (AppBuilder), Third-party product |
Feature | Security |
Mobile development type | Hybrid (Cordova app) |
Mobile OS | Android |
Description
Application packages cannot be completely secured from reverse-engineering. Instead, it is recommended to use tools for code obfuscation and secure any proprietary code on a server. This article shows how to create a small custom plugin that enables ProGuard and obfuscates all Java code that is present in your {{site.ab}} {{site.ac}} application.
Solution
-
Create an empty folder.
-
Inside the folder, create three files -
package.json
,plugin.xml
,enable-proguard.gradle
. -
The
package.json
file contains only the most basic information required by a {{site.ac}} plugin. For example:{ "name": "proguardplugin", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC" }
-
The
plugin.xml
file is used to reference theenable-proguard.gradle
file and include it in your app. For example:<?xml version="1.0" encoding="UTF-8"?> <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="proplugin" version="0.0.1"> <name>proplugin</name> <framework src="enable-proguard.gradle" custom="true" type="gradleReference"/> </plugin>
-
The
enable-proguard.gradle
file contains the logic required to enable ProGuard and obfuscate your code.android { buildTypes { release { minifyEnabled true proguardFile getDefaultProguardFile('proguard-android.txt') } } }
-
The last step is to archive the folder containing those files and import it to your app as a custom plugin.
Notes
Obfuscation with ProGuard in {{site.ab}} can also be achieved by modifying an already existing custom plugin. This can be accomplished by adding the enable-proguard.gradle
file to the plugin folder and referencing it in plugin.xml
.