1

I migrated yesterday my project to AndroidX. All xml layout files were correctly adjusted according to the migration rules ( https://developer.android.com/jetpack/androidx/migrate) .

Even so, I have tremendous amount of errors from databinding. I am importing different objects in the data section of xml layout files. But in the auto-generated dabinding classes, it does not recognize the sub-packages (e.g. I import com.myproject.app.Calibration.myViewModel; in CalibrationActivityBinding.java it does not recognize the com.myproject.app.Calibration subpackage. The same code used to work perfectly before migration to AndroidX.

I read this article Androidx and databinding but did not help me in solving my issues.

Has anybody encountered the same issues?

George Radu
  • 111
  • 1
  • 11
  • 1
    In your gradle.properties did you add android.useAndroidX=true android.enableJetifier=true android.databinding.enableV2=true ? –  Dec 11 '18 at 16:26
  • Yes, they were automatically added by Android Studio when I did the migration. – George Radu Dec 13 '18 at 06:09
  • I'm also facing same issue. Did you resolve this? – alex Oct 15 '19 at 07:13
  • @alex, since that moment I migrated more projects to Android X. Look in build.gradle (Project level): "classpath 'com.android.tools.build:gradle:3.4.1' // intentionally we do not go to 3.5.0 or 3.5.1 because dataBinding issues are not resolved". So probably you tried with the last tools 3.5.0 or 3.5.1. Try to downgrade to 3.4.1. Also, on gradle.properties I use " org.gradle.jvmargs=-Xmx1536m android.useAndroidX=true android.enableJetifier=true android.databinding.enableV2=false". Let me know if these work for you. If yes, cand you please upvote my answer and question? – George Radu Oct 30 '19 at 09:29

0 Answers0