Proguard examples?

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

brendan7
Posts: 43
Joined: 10 Feb 2014, 17:40

Proguard examples?

Postby brendan7 » 24 Jun 2014, 05:16

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.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Proguard examples?

Postby Lapo » 24 Jun 2014, 09:48

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 :)
Lapo
--
gotoAndPlay()
...addicted to flash games
brendan7
Posts: 43
Joined: 10 Feb 2014, 17:40

Re: Proguard examples?

Postby brendan7 » 24 Jun 2014, 19:31

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.
brendan7
Posts: 43
Joined: 10 Feb 2014, 17:40

Re: Proguard examples?

Postby brendan7 » 24 Jun 2014, 23:54

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.** { *; }
mihi
Posts: 12
Joined: 03 May 2018, 18:38

Re: Proguard examples?

Postby mihi » 16 May 2018, 15:56

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
mihi
Posts: 12
Joined: 03 May 2018, 18:38

Re: Proguard examples?

Postby mihi » 16 May 2018, 17:12

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.

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 8 guests