Volley seems not working after ProGuard obfuscate

ぃ、小莉子 提交于 2019-11-28 03:19:50

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/21816643/volley-seems-not-working-after-proguard-obfuscate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!