Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
323 views
in Technique[技术] by (71.8m points)

android - How to make Proguard ignore external libraries?

I want to use Proguard mainly for obfuscation reasons.

My problem is that I have three libraries, Twitter4J and two signpost libraries. These libraries caused errors when I tried to create an signed APK. To get over this I put the following in the proguard.config file...

-dontwarn org.apache.commons.codec.binary.** 
-dontwarn org.slf4j.** 
-dontwarn com.sun.syndication.io.**
-dontwarn com.sun.syndication.feed.synd.*   

While this got rid of the errors in the console, when i loaded my signed APK onto my mobile phone it instantly crashed. The DDMS said this was due to a class not found in Twitter4J.

Getting rid of the "dontwarns" above did not help. Neither did adding dontshrink dontoptimise.

I would like Proguard to completely ignore the libraries (as they are open source anyway). Is this possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try this:

-keep class javax.** { *; }
-keep class org.** { *; }
-keep class twitter4j.** { *; }

Cf post from @CaspNZ: Android Proguard with external jar


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...