[英]app:layout_behavior XML crash if productFlavors used
让 FAB 按钮为:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@id/appbar"
app:layout_anchorGravity="bottom|left|end"
app:srcCompat="@drawable/ic_arrow_drop_down"
app:layout_behavior=".ScrollingFABBehavior"
/>
...其中 ScrollingFABBehavior 是
public class ScrollingFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> {
它在主要风味(com.xxx.flavor1)中完美运行,但第二种风味让我崩溃:
Caused by: android.view.InflateException: Binary XML file line #108 in com.xxx.flavor2:layout/main: Could not inflate Behavior subclass com.xxx.flavor2.ScrollingFABBehavior
如果我以编程方式设置行为,它在第一和第二风格中都能完美运行。 因此看起来风味系统在 XML 处理中被破坏了。 您不知道如何在 XML 中正确修复它吗?
ps 如果为 AppBarLayout 设置行为,则完全相同的崩溃。
是的,您是对的,库有问题,当您添加自定义行为时,proguard 无法链接它,并修剪它(当您通过 xml 使用它时)。 如果你想通过 xml 使用它,那么你将不得不强制 proguard 不修剪这个文件,这个问题之前也被报告过。 检查以下链接。 https://stackoverflow.com/a/30846201/3497972
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.