Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Volley seems not working after ProGuard obfuscate

I have an Android app which uses Google Volley as my download broker. I just tried to use ProGuard to obfuscate the code, and find out the volley download starts failing at runtime.

Here's my ProGuard config:

-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep class com.actionbarsherlock.** { *; }
-keep interface com.actionbarsherlock.** { *; }
-keep class com.android.volley.** { *; }
-keep interface com.android.volley.** { *; }

-keepattributes *Annotation*

-dontwarn org.apache.**

and here is the error I saw in the code:

Async download FAILED. Exception message: The chosen LogFactory implementation does not extend LogFactory. Please check your configuration. (Caused by java.lang.ClassCastException: The application has specified that a custom LogFactory implementation should be used but Class 'org.apache.commons.logging.impl.LogFactoryImpl' cannot be converted to 'a.a.a.b.c'. Please check the custom implementation. Help can be found @http://commons.apache.org/logging/troubleshooting.html.)

I was wondering if I did some proguard config caused some dependency problem. Please help out.

like image 780
Allan Jiang Avatar asked Feb 16 '14 21:02

Allan Jiang


People also ask

How does ProGuard obfuscation work?

In the obfuscation step, ProGuard renames classes and class members that are not entry points. In this entire process, keeping the entry points ensures that they can still be accessed by their original names. The preverification step is the only step that doesn't have to know the entry points.

Should I use ProGuard?

Android apps are quite easy to reverse engineer, so if you want to prevent this from happening, you should use Proguard for its main function: Obfuscation. The other two important functions of Proguard are Shrinking and Optimization. Shrinking eliminates unused codes and it is highly useful.

Is ProGuard enabled by default?

Proguard is basically integrated into the Android Build System. And it runs only when the build of your application is in the release mode. You can choose to use Android Proguard as it is not compulsory but is highly recommended.


1 Answers

The Apache logging library uses some reflection on its log factories. Keeping their names should be sufficient:

-keep class org.apache.commons.logging.**

Side-note on your configuration: -keep class ..... always implies -keep interface ....., so you can leave out the latter.

like image 123
Eric Lafortune Avatar answered Nov 15 '22 16:11

Eric Lafortune