I'm working on an Android application with databinding but I've always next error:
Error: Package
my.package.databinding
does not exist.
Here is my build.gradle
on project level:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I've also enabled binding in the build.gradle
file on module level.
Now my question is, why occurs this error and how could I solve it?
The Data Binding Library is a support library that allows you to bind UI components in your layouts to data sources in your app using a declarative format rather than programmatically. Layouts are often defined in activities with code that calls UI framework methods.
You can't use them togheter in the same layout. ViewBinding is a subset of what DataBinding can do and should be used if you want to replace libraries like ButterKnife , KotterKnife or KAE (Kotlin Android Extensions) but don't want to invest in databinding refactoring.
The one and only function of View Binding is to bind the views in the code, while Data Binding offers some more options like Binding Expressions, which allows us to write expressions the connect variables to the views in the layout.
This problem occurs usually if your project does not compile. Android databinding should generate code in the named package, but it can't do that if the project doesn't compile in the first place.
To solve this, bring your project to a point where it compiles. If necessary, turn databinding off for this.
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