Smack For Android Fails When Using Proguard
I am using the smack library (4.1.2) in my Android app to connect to an XMPP server. It runs perfectly well when the code is NOT minified (ie with proguard). But in release mode, w
Solution 1:
So, I found a solution. Can't believe I spend a whole day on this problem! Hope this saves someone else the same trouble:
The line causing the problem (in smack library) is
stanzaType = (Class<S>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
Note the cast. The problem appears to be the proguard by default looses some information on types, even if you have specified "-keep" for your classes. The crucial bit of helpful information is here: Field.getGenericType() returns instance of java.lang.Class instead of Type
The answer to my question is therefore that the following proguard config is required:
-keepattributes Signature-keep class org.jivesoftware.smack.** { *; }-keep class org.jivesoftware.smackx.** { *; }
Solution 2:
xpp3 need to proguard too if you notadd this
configurations {
all*.exclude group: 'xpp3', module: 'xpp3'
}
Post a Comment for "Smack For Android Fails When Using Proguard"