Search code examples
androidandroid-gradle-pluginandroid-databindingandroidx

Android data binding "Missing import expression although it is registered" after upgrade to gradle 5.0


After I upgrade my Android studio to 3.4, Android Gradle Plugin to 3.4 and gradle to 5.1.1

I got the data binding errors like below

I have made sure I cleaned project and rebuild, I have cleared cache and restarted AS.

This issue never happened before the upgrade

I can confirm it is because of the new gradle update

DataBinderMapperImpl.java:54: error: cannot find symbol

e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors. ****/ data binding error ****msg:Missing import expression although it is registered

I found the solution: Solution:

  1. Now 3.4.1 released, use 3.4.1
  2. Remove all import type in layout XML
  3. Remove all string from import type in layout XML
  4. Remove all integer from import type in layout XML

Solution

  • After I upgraded my Android studio and gradle plugin, I ran into similar issue because of the below line. I was using this <import type="java.lang.String" /> in my layout file. Removing this import solved the issue.

    Just as in managed code, java.lang.* is imported automatically.