Proguard: How to keep everything except specific condition?

删除回忆录丶 提交于 2020-01-01 06:27:12

问题


I'm using Proguard to obfuscate my code, and I need to keep every third party libraries like:

-keep class com.layer.**
-dontwarn com.layer.**
-keep class com.twitter.**
-keep class android.support.**
-keep class com.crashlytics.** { *; }
-dontwarn com.crashlytics.**
...

And whenever I add a new third party library, I need to check its package name and add it to my proguard config file, or the app may crashes.

Can't I write the rule just like this? I don't care about codes that's not mine.

-keep class !(my.package.name.**)
-dontwarn !(my.package.name.**)

Thanks!


回答1:


To keep everything except classes in your own package you can use the rule that you already pointed out (excluding the brackets):

-keep class !my.package.name.** { *; }

This will implicitly keep everything else. You still can add additionally -keep rules for your classes if needed.

The rule for the -dontwarn should work in a similar way:

-dontwarn !my.package.name.**,**

You can also add similar -dontnote rules if needed.



来源:https://stackoverflow.com/questions/39421910/proguard-how-to-keep-everything-except-specific-condition

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