Android Proguard configuration for the v7 Support Library ActionBar

余生颓废 提交于 2019-12-28 16:45:48

问题


I'm using the v7 Support Library to show an ActionBar on Android 2.x. It works well enough but I had to fix a few class/method not found errors after enabling Proguard.

Are there any guidelines on which classes need to be preserved?

So far I have these:

-keep public class android.support.v7.internal.widget.ActionBarContainer
-keep class android.support.v7.internal.widget.ActionBarView$HomeView
-keep public class android.support.v7.internal.widget.ActionBarContextView

It seems to work now but I'm not that confident that it won't crash at some stage because of some other supposedly internal class referenced in some XML file.


回答1:


I solved it with:

-dontwarn android.support.v7.**
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }



回答2:


I use this, somewhat similar to what the v4 version suggested:

-keep class android.support.v7.internal.** { *; }
-keep interface android.support.v7.internal.** { *; }



回答3:


I got it from Android Proguard Snippet

-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }

-keep public class * extends android.support.v4.view.ActionProvider {
    public <init>(android.content.Context);
}

Hope it will work.



来源:https://stackoverflow.com/questions/18290108/android-proguard-configuration-for-the-v7-support-library-actionbar

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