利用AppCompat“layout_behavior”与“@字符串/ appbar_scrolling_view_behavior”抛出异常 [英] Using AppCompat 'layout_behavior' with '@string/appbar_scrolling_view_behavior' throws exception
问题描述
我有一个奇怪probem使用AppCompat库22.2新介绍:layout_behavior
I have a strange probem using the AppCompat Lib 22.2 with the new introduced: layout_behavior
如果我使用它的价值@字符串/ appbar_scrolling_view_behavior,这里所描述的 Android的设计支持库中的应用程序与下面的异常终止:
If i use it with the value "@string/appbar_scrolling_view_behavior" , as described here Android Design Support Lib the application terminates with the following exception:
Could not inflate Behavior subclass android.support.design.widget.Settings
Caused by: java.lang.RuntimeException: Could not inflate Behavior subclass android.support.design.widget.Settings
Caused by: java.lang.ClassNotFoundException: android.support.design.widget.Settings
Caused by: java.lang.NoClassDefFoundError: android/support/design/widget/Settings
Caused by: java.lang.ClassNotFoundException: android.support.design.widget.Settings
如果我更改为:
app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"
一切工作正常。
everything works fine.
什么我失踪?
推荐答案
有关其他人谁遇到这样的异常,并使用ProGuard的 - 你需要添加以下ProGuard的规则:
For others who encounter this exception and use proguard - you need to add following proguard rules:
-keep class android.support.design.widget.** { *; }
-keep interface android.support.design.widget.** { *; }
-dontwarn android.support.design.**
如果你不想让所有的设计库组件可以使用的:
or if you don't want to keep all of the design library components you can use:
-keepattributes *Annotation*
-keep public class * extends android.support.design.widget.CoordinatorLayout.Behavior { *; }
-keep public class * extends android.support.design.widget.ViewOffsetBehavior { *; }
这篇关于利用AppCompat“layout_behavior”与“@字符串/ appbar_scrolling_view_behavior”抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!