I have a working Android Studio project, also installed via USB on my smartphone, it's a simply basic calculator. Now I have to rewrite the code for a lesson I teach, but Android Studio denies this import
import [com.username.projectname].databinding.ActivityMainBinding;
The app uses dataBinding I have enabled in Module:app and resync everything.
The old project works, the new one not, with the same code, cause of this import is refused.
The XML
needs a <layout>
wrap alike this ...so that the desired class will be generated:
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data class=".databinding.ActivityMainBinding">
<!-- add variables & imports into here -->
</data>
<!-- and add the RelativeLayout into here -->
</layout>
Just add in the module based Grade file, the following
buildFeatures{
viewBinding true
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With