[英]app:layout_behavior XML crash if productFlavors used
Let FAB button be:让 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"
/>
...where ScrollingFABBehavior is ...其中 ScrollingFABBehavior 是
public class ScrollingFABBehavior extends CoordinatorLayout.Behavior<FloatingActionButton> {
It works perfectly in main flavor (com.xxx.flavor1), but second flavor gives me crash:它在主要风味(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
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
If I set the behavior programmatically, it works perfectly both in first and second flavors.如果我以编程方式设置行为,它在第一和第二风格中都能完美运行。 Thus looks like flavor system is broken in XML processing.
因此看起来风味系统在 XML 处理中被破坏了。 Don't you know how to fix it right in XML?
您不知道如何在 XML 中正确修复它吗?
ps Exactly the same crash if set behavior for AppBarLayout. ps 如果为 AppBarLayout 设置行为,则完全相同的崩溃。
Yes you are right, there is something wrong with library, when you add your custom behaviour, proguard is not able to link it, and prunes it (when you use it via xml).是的,您是对的,库有问题,当您添加自定义行为时,proguard 无法链接它,并修剪它(当您通过 xml 使用它时)。 If you want yo use it via xml then you will have to force proguard to not prune this file, This issue has earlier been reported too.
如果你想通过 xml 使用它,那么你将不得不强制 proguard 不修剪这个文件,这个问题之前也被报告过。 check the below link.
检查以下链接。 https://stackoverflow.com/a/30846201/3497972
https://stackoverflow.com/a/30846201/3497972
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.