I have configurated databinding in android app project like below. and I get error on every field which is defined in xml file (as variable). I don't know if it's related but I use the newest android studio.
I use only debug. Yes also i try clean project. ivalidate and restart android studio. Unistall app and isntal to clean device. I also made factory reset on my Mi Box.
android {
compileSdkVersion "28.0.3"
defaultConfig {
applicationId "pl.myapp.app"
minSdkVersion 23
targetSdkVersion 28
versionCode 28
versionName "1"
resConfigs "en", "pl"
}
buildFeatures {
dataBinding = true
}
buildTypes {
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
uat {
applicationIdSuffix ".uat"
debuggable true
minifyEnabled false
}
debug {
applicationIdSuffix ".dev"
debuggable true
minifyEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
disable "NotSibling"
abortOnError false
}
}
but I get exception (and app crashes) with:
java.lang.NoSuchFieldError: No static field episode of type I in class Lpl/myapp/mobile/tv/BR; or its superclasses (declaration of 'pl.myapp.mobile.tv.BR' appears in /data/app/pl.myapp.app.atv.dev-WdbOpjR9fmv54PzXTST74w==/base.apk:classes2.dex)
at pl.myapp.mobile.tv.databinding.MainSectionItemCardBindingImpl.setEpisode(MainSectionItemCardBindingImpl.java:88)
at pl.myapp.mobile.tv.ui.gui.view.cards.SectionCardPresenter.onBindViewHolder(SectionCardPresenter.kt:25)
at pl.myapp.mobile.tv.ui.gui.view.cards.SectionCardPresenter.onBindViewHolder(SectionCardPresenter.kt:12)
at pl.myapp.mobile.tv.ui.BasePresenter.onBindViewHolder(BasePresenter.kt:35)
at androidx.leanback.widget.Presenter.onBindViewHolder(Presenter.java:140)
at androidx.leanback.widget.ItemBridgeAdapter.onBindViewHolder(ItemBridgeAdapter.java:400)
at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
at androidx.leanback.widget.GridLayoutManager.measureScrapChild(GridLayoutManager.java:1288)
at androidx.leanback.widget.GridLayoutManager.processRowSizeSecondary(GridLayoutManager.java:1372)
at androidx.leanback.widget.GridLayoutManager.onMeasure(GridLayoutManager.java:1476)
at androidx.recyclerview.widget.RecyclerView.onMeasure(RecyclerView.java:3593)
at android.view.View.measure(View.java:21998)
Fragment of MainSectionItemCardBindingImpl class:
public void setEpisode(@Nullable pl.myapp.mobile.tv.ui.model.MainCarouselItem Episode) {
this.mEpisode = Episode;
synchronized(this) {
mDirtyFlags |= 0x1L;
}
notifyPropertyChanged(BR.episode); //line 88
super.requestRebind();
}
Fragment of SectionCardPresenter class:
override fun onBindViewHolder(viewHolder: DataBoundLeanbackViewHolder<MainSectionItemCardBinding>, item: MainCarouselItem?) {
viewHolder.binding.episode = item //line 25
viewHolder.binding.root.setOnClickListener { onItemClickListener?.invoke(item) }
and fragment of xml file:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.view.View" />
<variable
name="episode"
type="pl.myapp.mobile.tv.ui.model.MainCarouselItem"/>
</data>
all other binding are working like access to views via binding object.