Page 1 of 1

Proguard examples?

Posted: 24 Jun 2014, 05:16
by brendan7
Hi all,

Due to having a very large project, I need to use proguard to shrink things down.

Does anybody have an example of a working proguard config for an android app? I would be very grateful.

Specifically, I am getting this error:
E/AndroidRuntime(3268): java.lang.NoClassDefFoundError: org.slf4j.impl.StaticLoggerBinder

I have tried fixing it with this line in my proguard:
-keep class org.slf4j.** { *; }

But I still get the same error. I am thinking the class is called indirectly through an implementation or something.

Any help with proguard examples would be fantastic, thanks.

Re: Proguard examples?

Posted: 24 Jun 2014, 09:48
by Lapo
The problem with shrinking support libraries is that you don't know what they do at runtime and failure may pop up at any time.
I wouldn't recommend it.

Anything that uses reflection or dynamic class loading (as slf4j) may fail at some point but you'll never know unless you thoroughly test your application. It's a little bit of a crapshoot, imho :)

Re: Proguard examples?

Posted: 24 Jun 2014, 19:31
by brendan7
Thanks Lapo. I wish there were a way to tell proguard to keep everything in the SFS support library. If I can't find a way to force it, I guess I will have to turn parts of my code into plugins with multiple dex files.

Re: Proguard examples?

Posted: 24 Jun 2014, 23:54
by brendan7
Turns out my problems were from gradle not packing a jar.

To be safe in proguard, I ended up just listing classes to exclude (big ones that were part of certain jars but I didn't use). That way I know all SFS code makes it in. Did something like this:

-keep class !com.google.android.gms.wallet.**,!com.google.android.gms.maps.** { *; }

Re: Proguard examples?

Posted: 16 May 2018, 15:56
by mihi
I have this problem to

When i build my project in android i get some errors about sfs.
How can i exclude sfs libraries from proguard?

Thanks

Re: Proguard examples?

Posted: 16 May 2018, 17:12
by mihi
Hi,

I did many searches to solve the problem, but finally i solved the that myself:

-keep class org.python.*{ *; }
-dontwarn org.python.**
-keep class com.smartfoxserver.*{ *; }
-dontwarn com.smartfoxserver.**
-keep class org.jaxen.*{ *; }
-dontwarn org.jaxen.**
-keep class java.rmi.*{ *; }
-dontwarn java.rmi.**
-keep class org.jboss.*{ *; }
-dontwarn org.jboss.**

just use above lines in your proguard
Thanks.