如何让Proguard忽略外部库?

Mel*_*Mel 47 android proguard android-library

我想使用Proguard主要是出于混淆的原因.

我的问题是我有三个库,Twitter4J和两个路标库.当我尝试创建签名的APK时,这些库会导致错误.为了克服这个问题,我在proguard.config文件中添加了以下内容......

-dontwarn org.apache.commons.codec.binary.** 
-dontwarn org.slf4j.** 
-dontwarn com.sun.syndication.io.**
-dontwarn com.sun.syndication.feed.synd.*   
Run Code Online (Sandbox Code Playgroud)

虽然这摆脱了控制台中的错误,当我将签名的APK加载到我的手机上时,它立即崩溃了.DDMS说这是由于Twitter4J中没有找到的课程.

摆脱"dontwarns"上述情况并没有帮助.也没有添加dontshrink dontoptimise.

我希望Proguard完全忽略这些库(因为它们无论如何都是开源的).这可能吗?

Mur*_*phy 63

试试这个:

-keep class javax.** { *; }
-keep class org.** { *; }
-keep class twitter4j.** { *; }
Run Code Online (Sandbox Code Playgroud)

来自@CaspNZ的帖子: 带有外部jar的Android Proguard


Nic*_*ong 11

您应该能够向proguard.cfg添加以下行以排除包(和子包)中的所有类

-keep class org.apache.commons.codec.binary.**
-keep interface org.apache.commons.codec.binary.**
-keep enum org.apache.commons.codec.binary.**
-keep class org.slf4j.**
-keep interface org.slf4j.**
-keep enum org.slf4j.**
-keep class com.sun.syndication.io.**
-keep interface com.sun.syndication.io.**
-keep enum com.sun.syndication.io.**
-keep class com.sun.syndication.feed.synd.**
-keep interface com.sun.syndication.feed.synd.**
-keep enum com.sun.syndication.feed.synd.**
Run Code Online (Sandbox Code Playgroud)