• Twitter
  • Facebook
  • Google+
  • Instagram

Skills & Things about me

Music
85%
Android
Punctual
80%
iOS
Mobile Developer
Problem Solving

Keeping Entire Package Using Proguard

Keeping Entire Package Using Proguard

Pro-guard was released in 2002 and since it's first public release it has been downloaded over tens of  millions times by more than one million developers. Pro-guard is mainly used for obfuscating applications. Also, shrinking the unused code and optimization of the Java byte-code is catered by Pro-guard. Since, Android uses Dalvik byte code, some optimizations doesn't work well.

There are always some scenarios, in which, we need to keep some of our packages from being obfuscated by Pro-guard. The most popular scenario is when we are using GSON and we have got models (POJO) that are used by GSON library. In this post we are going to dig into the ways of keeping entire packages from Pro-guard.

There are several ways of achieving this, we will look into them one by one.
1. Keeping names of public classes:
-keep public class com.salmankhakwani.application.network.gson.models.*

2. Keeping names of public classes for packages and sub-packages:
-keep public class com.salmankhakwani.application.network.gson.models.**

3. Keeping names of public/protected/private classes/methods/fields for packages and sub-packages:
-keep public class com.salmankhakwani.application.network.gson.models.** {
  public protected private *;
}

I hope this helps anyone who got into similar scenario of keeping packages from Pro-guard.

Contact

Get in touch with me


Email adress

me@salmankhakwani.com

Phone number

+(92) 343 201 2045

Website

www.salmankhakwani.com