开发者

Issues with Android ADT, Proguard and External Jars

开发者 https://www.devze.com 2023-02-07 00:05 出处:网络
So, I\'m trying to get the ADT\'s built-in proguard implementation working for my app. Unfortunately, it seems to be choking on various classes in third-party libraries I references.

So, I'm trying to get the ADT's built-in proguard implementation working for my app. Unfortunately, it seems to be choking on various classes in third-party libraries I references. I've tried various, if not all, the combinations of -libraryjars and -keep public class line开发者_如何学Pythons I can think of, but it's all to no good. I'm not that experienced with Proguard, so honestly, I don't know where I'm going wrong. I've tried google, but most of the information relates to Ant scripts.

Some of the things I've tried:

  • Lines like -libraryjars C:\Users\Dave\workspace\Dropbox_Sync_for_Tasker_and_Locale\lib\apache-mime4j-0.6.jar at the top or bottom of the file

  • Lines attempting to make paths to jars like that relatively, to no success at all.

  • Lines like -keep public class org.apache.commons.logging.LogFactory

  • Line that refer to the other part of the error lines, like -keep public class org.apache.james.mime4j.field.MailboxListField

Anyway, the error log is a huge wall of text, so I've put it on a pastebin here.


So, if you happen to find this answer, and are like, hm, I have that problem too, I wish he posted his solution, you're half in luck.

The way I fixed it was to just stick the -libraryjars lines in there, and then

-dontwarn org.apache.commons.logging.LogFactory
-dontwarn net.jcip.annotations.NotThreadSafe
-dontwarn net.jcip.annotations.ThreadSafe
-dontwarn net.jcip.annotations.Immutable

And it worked fine. It's a hack, and it's dirty, but it solved it for me. Unfortunately, you're still on your own if you too have this problem.


I had exactly the same problem after adding "apache-mime4j-0.6.1.jar" and "httpmime-4.0.1.jar" to my project. (for multipart POST'ing of binary data to my server).

I am also not familiar with pro-guard but at least I've managed to add my custom widget to the proguard.cfg - unfortunately the apache library proved even more difficult to add !

this is my fix... I have this added to the bottom of proguard.cfg :

#APACHE LIBRARY
-libraryjars /libs/apache-mime4j-0.6.1.jar
-libraryjars /libs/httpmime-4.0.1.jar
-keepnames class org.apache.** {*;}
-keep public class org.apache.** {*;}
-dontwarn org.apache.commons.logging.LogFactory
-dontwarn org.apache.http.annotation.ThreadSafe
-dontwarn org.apache.http.annotation.Immutable
-dontwarn org.apache.http.annotation.NotThreadSafe

I was hoping that the first 4 lines would be the fix. Unfortunately the dontwarn's are needed to really "fix" it.

Correct me if I am wrong (since I'm no proGuard pro), but I believe the first 4 lines make sure that the libraries are used as-is. The second section of four lines (dontwarn) just cover up the remaining crap and don't correct some underlying issue. What the underlying issue is I don't know.


try downloading the commons-logging.jar, put it in your libs and add a -libraryjars to your proguard config.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号