【问题标题】:cannot generate view binders java.lang.StackOverflowError无法生成视图活页夹 java.lang.StackOverflowError
【发布时间】:2019-11-07 11:52:14
【问题描述】:

尝试将应用程序从支持迁移到 androidx for android 29。在 android studio 中出现错误无法生成视图活页夹 java.lang.StackOverflowError。错误未显示任何文件名或行号。

在探索了可能的解决方案后,我发现这个问题与 Binding 适配器有关。

迁移应用时,一段代码由 android studio 自动转换。

旧代码

android:visibility="@{rating.isExtended.get()?View.VISIBLE:View.GONE}"

新代码

android:visibility="@{safeUnbox(rating.isExtended.get())?View.VISIBLE:View.GONE}"

我关注了this链接并使用了sn-p。

@BindingAdapter("app:goneUnless")
public static void goneUnless(View view, Boolean visible) {
    view.visibility = visible ? View.VISIBLE : View.GONE;
}

现在问题已解决。

【问题讨论】:

    标签: android android-studio androidx


    【解决方案1】:

    错误是因为您的layout xml file 中存在getValue()get()

    在我的一个 layout.xml 文件中,我写了mutableLiveDataVariable.getValue(),这是一种错误的做法。当我的工作室版本是 3.5.1 时,它可以工作,没有出现任何错误。

    一旦我将它更新到 3.5.3。我开始收到cannot generate view binders java.lang.StackOverflowError。所以我删除了getValue() 并将我的代码更改为 android:text="@={viewModel.firstName}"

    它奏效了。

    请检查以下链接,报告的位置。

    https://issuetracker.google.com/issues/143778134

    https://issuetracker.google.com/issues/144604674

    【讨论】:

      猜你喜欢
      • 2018-03-23
      • 2018-03-23
      • 2017-06-22
      • 2011-12-22
      • 1970-01-01
      • 2017-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多