Obfuscate your Android application

Proguard is the nice way to obfuscate your Android application to prevent reverse engineering. Here is Google tutorial for this http://developer.android.com/guide/developing/tools/proguard.html.

But you can face some difficulties with it:

  1. To minimize risk of “class not found” exceptions – don’t obfuscate external libraries that you have in your project. Add -keep option to proguard.cfg
    -keep public class com.google.ads.** {
        public protected *;
  2. If you are using reflection in your code – add these classes to the exclude list:
    -keepclassmembers class * {
        public static void buildUriMatcher(android.content.UriMatcher, java.lang.String);
  3. Stop using onClick listeners in xml resources!:) Or also add an exception:
    public void on*(android.view.View);
  4. In Eclipse you can easily get “conversion to dalvik format failed with error 1”:

    Don’t worry – don’t obfuscate external libraries + don’t use Eclipse for export signed application. Just create build.xml for Ant and all will be just perfect!

    Read more about this problem here: http://bimbim.in/post/2010/09/24/Reason-of-Conversion-to-dalvik-format-failed-with-error-1.aspx

  5. Try to reverse engineering your code with JD (as described here). You may need to remove some debug log String constants to make your code completely unreadable:)



How to decompile Android application

It’s quite easy to decompile Android application and take a look into it:)

  1. Download dex2jar tool (thanks to the creator!) http://code.google.com/p/dex2jar/
  2. Find apk that you want to decompile (like Twitter_v1.0.5.apk)
  3. Use dex2jar.bat Twitter_v1.0.5.apk – get Twitter_v1.0.5.apk.dex2jar.jar
  4. Download Java Decompiler
  5. Open jar file – enjoy pure java code:)

java decompiler (dex android)

If you want to take a look into AndroidManifest.xml:

  1. Download AXMLPrinter2.jar
  2. Extract AndroidManifest.xml from apk file
  3. Use java -jar AXMLPrinter2.jar AndroidManifest.xml >> twitter_manifest.txt
  4. Enjoy readable AndroidManifest.xml

Hope you will learn a lot from somebody’s code and create a new powerful Android app! 🙂


© 2020 Android Tales

Theme by Anders NorenUp ↑