This morning I made an update to android studio
from 3.0.1 to 3.1.0. After updating the gradle
to latest version I still get build error regarding data binding.
My gradle-wrapper.properties
:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
All my errors are like the one below:
/Users/mp/Documents/GitHub/projectx/app/build/generated/source/dataBinding/baseClasses/Staging/debug/me/projectx/asdasd/databinding/GridItemActivityTypeBinding.java:57: error: cannot find symbol @Nullable DataBindingComponent component) { ^ symbol: class DataBindingComponent location: class GridItemActivityTypeBinding
Does anyone have any idea why would my data binding not generate after the android studio 3.1 update? Thanks in advance
Edit 1: Forgot to say, I tried clean/rebuild/invalidate cache & restart/deleted build folder.
Recently Android has announced that with Kotlin 1.4. 20, their Android Kotlin Extensions Gradle plugin will be deprecated and will no longer be shipped in the future Kotlin releases. Android Kotlin Extensions plugin brought with it two very cool features : Synthetics let you replace calls to findViewById with kotlinx.
View binding and data binding both generate binding classes that you can use to reference views directly. However, view binding is intended to handle simpler use cases and provides the following benefits over data binding: Faster compilation: View binding requires no annotation processing, so compile times are faster.
Why use Data binding with Mvp? Combining Databinding along wih MVP pattern can result in a very clean structure and maintainable project. Databinding saves u a lot of stress and uneccesary long lines of code. Your UI is updated eaily and gone are those days where you need "findViewById" and onclick listeners and so on.
To convert your XML layouts into the Data Binding layout, follow the below steps: Declare a <layout> tag, which will wrap your existing layout file at the root level. Declare variables under the <data> tag, which will go under the <layout> tag. Declare necessary expressions to bind data inside the view elements.
Following the update to Android Studio 3.2, this line works for me. I have both Java and Kotlin code (compiler) running in my project.
Add the following to your gradle.properties: android.databinding.enableV2=false
Reason:
Data Binding V2
Data Binding V2 is now enabled by default and is compatible with V1. This means that, if you have library dependencies that you compiled with V1, you can use them with projects using Data Binding V2. However, note that projects using V1 cannot consume dependencies that were compiled with V2.
source (Release Note): https://developer.android.com/studio/releases/
Just Commenting these lines out in graddle-wrapper.properties
file helped me solve my problem
#android.enableExperimentalFeatureDatabinding = true #android.databinding.enableV2=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