简体   繁体   English

app:layout_behavior XML 如果使用 productFlavors 则崩溃

[英]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.

相关问题 以编程方式设置 app:layout_behavior - Setting app:layout_behavior programmatically &#39;app:layout_behavior&#39; 应该在哪里设置? - Where should 'app:layout_behavior' be set? 还有其他app:layout_behavior预定义值吗? - Are there other app:layout_behavior predefined values? 在工具栏应用程序中永远不会调用自定义滚动行为:layout_behavior - custom scroll behavior is never called in toolbar app:layout_behavior Android NestedScrollView 在 app:layout_behavior 后尺寸错误 - Android NestedScrollView has wrong size after app:layout_behavior 无法在片段标签上设置 `app:layout_behavior` - Cannot set `app:layout_behavior` on fragment tag 为子片段禁用“ app:layout_behavior =” @ string / appbar_scrolling_view_behavior”” - Disable 'app:layout_behavior=“@string/appbar_scrolling_view_behavior”' for child fragment 谁能解释一下“app:layout_behavior =”@ string / appbar_scrolling_view_behavior“? - Can anyone explain me about “app:layout_behavior=”@string/appbar_scrolling_view_behavior"? 我应该实现哪个库来使用 app:layout_behavior=“@string/appbar_scrolling_view_behavior” - which library should i implement to use app:layout_behavior=“@string/appbar_scrolling_view_behavior” Android Studio layout_behavior 错误 - Android Studio layout_behavior error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM