简体   繁体   中英

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

I just updated AndroidStudio to 3.0.1 from 2.3 version for one of my projects. AndroidStudio is now complaining about data binding issue when I try to build the project. I am using alpha release of gradle classpath

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. 

The line it's complaining about uses two-way data binding with 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}"/>

The viewModel is an instance of class whose parent(BaseViewModel) extends BaseObservable .

Please note that it was working fine previously and it stopped working when I updated AndroidStudio . I tried clean/build and invalidate/restart options, no luck. I would really appreciate any pointers on what I'm missing.

For my case there were more than one issues. My app used many library modules residing on different repo. So I updated each module to use same gradle version( I used 3.1.0 ). Then I also updated the databinding library version. dataBinding { enabled = true version '2.3.3' } Hope it will help others.

I faced the same issue, spent hours on trying to find what is wrong with the code which was related to binding and inverse binding of spinner.

After upgrading Android studio to 3.0.1 and upgrading Gradle, the compile error was gone.

I have the same issue with databinding 3.1.0-alpha07/ Android Studio 3.1 Canary 7 I tried clean/restart too. I tried to downgrade to 3.1.0-alpha06, with no effect. The only workaround that temporary worked, was to deleted every databinding lines with error, compile, and then put them again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM