在 null 上找不到值类型为 java.lang.String 的属性 'android:text' 的 getter

Cannot find the getter for attribute 'android:text' with value type java.lang.String on null

我刚刚将我的一个项目的 AndroidStudio 从 2.3 版本更新到 3.0.1。当我尝试构建项目时,AndroidStudio 现在抱怨数据绑定问题。我正在使用 gradle classpath

的 alpha 版本
com.android.tools.build:gradle:3.1.0-alpha07

Error:(67, 17) Cannot find the getter for attribute 'android:text' with value type java.lang.String on null. 

它抱怨的行使用双向数据绑定EditText

<android.support.design.widget.TextInputEditText
                android:id="@+id/groupNumber"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="@string/text_hint"
                android:imeOptions="actionNext"
                android:maxLength="@{viewModel.maxLength}"
                android:maxLines="1"
                android:text="@={viewModel.title}"
                android:textColor="@color/red"
                app:filter="@{viewModel.inputType}"/>

viewModel 是 class 的实例,其 parent(BaseViewModel) 扩展 BaseObservable

请注意,它之前工作正常,当我更新 AndroidStudio 时它停止工作了。我尝试了 clean/buildinvalidate/restart 选项,但没有成功。我真的很感激任何关于我所缺少的东西的指示。

我对数据绑定 3.1.0-alpha07/ Android Studio 3.1 Canary 7 也有同样的问题 我也试过clean/restart。我试图降级到 3.1.0-alpha06,但没有效果。 唯一临时有效的解决方法是删除所有有错误的数据绑定行,编译,然后重新放置它们。

我的情况不止一个问题。我的应用程序使用了许多驻留在不同 repo 上的库模块。所以我更新了每个模块以使用相同的 gradle 版本(我使用 3.1.0)。 然后我还更新了数据绑定库版本。 dataBinding { enabled = true version '2.3.3' } 希望对其他人有帮助。

我遇到了同样的问题,花了几个小时试图找出与微调器的绑定和反向绑定相关的代码有什么问题。

studio升级Android到3.0.1后,升级Gradle,编译错误消失