0

I'm migrating a project to AndroidX and have the following error :

Caused by: java.lang.RuntimeException: android.databinding.tool.util.LoggedErrorException: Found data binding errors. ****/ data binding error ****msg:Cannot find the setter for attribute 'android:visibility' with parameter type int on androidx.constraintlayout.ConstraintLayout

And the layout having the issue is :

<androidx.constraintlayout.ConstraintLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content"
  android:layout_centerInParent="true"
  android:visibility="@{myVar == STRING_SUCCESS ? View.GONE : View.VISIBLE}">

I don't know where to start ... Any help is greatly appreciated

Molly
  • 1,887
  • 3
  • 17
  • 34
Ismail H
  • 4,226
  • 2
  • 38
  • 61

1 Answers1

4

Try using androidx.constraintlayout.widget.ConstraintLayout

ronginat
  • 1,910
  • 1
  • 12
  • 23
  • Thanks a lot ! Can you explain where the issue comes from please ? I have bunch of others like this ... – Ismail H Apr 08 '19 at 10:56
  • 1
    You just need to use the layout itself. Try pressing Ctrl+click the class `ConstraintLayout` in `androidx.constraintlayout.widget.ConstraintLayout` (in the xml). You'll get the actual class implementation, try again with your original 'layout' and discover that there is nothing behind it – ronginat Apr 08 '19 at 11:07
  • Life saver @ronginat ! – Ismail H Apr 08 '19 at 11:08
  • Just write the view name and let the IDE fill it for you. – ronginat Apr 08 '19 at 11:15
  • I had the same problem but with a different layout, `cannot find the setter for attribute 'android:visibility' with parameter type int on android.material.textfield.TextInputLayout` and I can't figure out the package to use for `TextInputLayout` – Ismail H Apr 08 '19 at 11:17
  • 1
    `android.material` is now `com,google.android.material`. Add `implementation com.google.android.material:material:1.1.0-alpha05` to your gradle (if you didn't already). Then use `com.google.android.material.textfield.TextInputLayout` – ronginat Apr 08 '19 at 11:22