Search code examples
proguardsmack

What are the recommended ProGuard rules for Smack 4.1?


What are the proper ProGuard rules for Smack 4.1 when building an Android release apk?

Currently, I'm using the rules from aSmack 4.0.x from the README.asmack file on the aSmack github repository which is outdated (references old class names, and intended for 4.0.x). I could not find any references to what the proper proguard rules to use for 4.1.x are, could anyone shed light on this?


Solution

  • What are the proper Proguard rules for Smack 4.1 when building an Android release apk?

    Depends on what "proper" means for you.

    The easiest way is likely to tell ProGuard to keep all classes and interfaces of Smack.

    -keep class org.jivesoftware.smack.** { *; }
    -keep class org.jivesoftware.smackx.** { *; }
    

    Alternatively you can configure ProGuard so that it only keeps those parts of Smack that you actually use, and let ProGuard strip everything else. But to do so, you'll need a good understanding how your App uses Smack. See for example the ProGuard configuration of MAXS's Transport XMPP: https://bitbucket.org/projectmaxs/maxs/src/75efeba8d8470b89da8cd8551304bb00648e4945/transport-xmpp/proguard-project.txt?at=master#cl-20

    Note that if you don't know exactly what are you doing, then Smack could behave unexpectedly or even crash. Only fine tune ProGuard if you know what you are doing!