I’ve been trying to see ProGuard in action with my test Android app. Do I need to register as an Android developer and have a key to do that? I know app needs to be built in release mode. I read these instructions several times on Android site among other things, it talks about what ProGuard does but not how to achieve it obfuscation in Android properly. Found another blog that shows how to do it with Ant, but not with Eclipse.
Share
No, you do not need to register as an Android developper to try the Proguard obfuscation. You just need to have Proguard installed and properly configured for your app.
Since a few month, the Android SDK comes with a distribution of Proguard directly integrated. Open your
<android-home>\toolsdirectory and check whether you find a directory calledproguardin it. If it is not the case, the best is to upgrade your SDK.Using Proguard is very simple with the integrated version of the Android SDK: you just have to declare what follows in the file
default.propertiesof your project:Then, you have to write your
proguard.cfgif it does not already exist. The Android SDK writes this file for you for any new project you create since it integrates Proguard, but if your project was created with a former version of the SDK this file won’t exist. The following file is suitable for most Android projects:When you compile in debug mode, there is no obfuscation. To obfuscate your code, you have to:
1- Ensure that your manifest file sets the debug mode to false:
2- Export your APK using the “File/Export” menu of Eclipse (provided you are using Eclipse, but who doesn’t? 🙂 ). There will be no obfuscation by just using the “Run” function as this is actually debugging.
Once done the obfuscation, you will find a
proguarddirectory in your project’s root directory. It will contain files that will allow you to inspect the obfuscated code, see what was obfuscated and what wasn’t, etc. The Proguard’s documentation will help you on that, that’s pretty simple.