How to fix cannot find symbol view-model-name-BindingImpl when using two-way databinding in AndroidData Binding class not generatedAndroid RecyclerView Adapter DataBinding - cannot find symbol layoutBindingImplIs there an easy way to add a border to the top and bottom of an Android View?How to change an Android app's name?“cannot resolve symbol R” in Android StudioTwo-Way databinding in EditTextAndroid databinding cannot resolve symbol (gradle 3.0.1)Android two-way databinding cannot get event onCheckedChanged to fireCustom View with Two-Way DatabindingAndroid two way data binding with room table modelsAndroid Databinding for Custom View: 'cannot find symbol' and 'duplicate class found'Convert one-way data binding to two-way using Android Architecture Components
What could be my risk mitigation strategies if my client wants to contract UAT?
Storing voxels for a voxel Engine in C++
Why is this integration method not valid?
Complications of displaced core material?
How does Dreadhorde Arcanist interact with split cards?
Merge pdfs sequentially
How to remove new line added by readarray when using a delimiter?
How do you earn the reader's trust?
Papers on ArXiv as main references
Why A=2 and B=1 in the call signs for Spirit and Opportunity?
Team has team lunch everyday, am I forced to go?
Alexandrov's generalization of Cauchy's rigidity theorem
Why did OJ Simpson's trial take 9 months?
"Official wife" or "Formal wife"?
The disk image is 497GB smaller than the target device
Ribbon Cable Cross Talk - Is there a fix after the fact?
Reduce size of sum sub/superscript?
Is it normal to "extract a paper" from a master thesis?
What is Orcus doing with Mind Flayers in the art on the last page of Volo's Guide to Monsters?
Why is 'additive' EQ more difficult to use than 'subtractive'?
Why did it take so long for Germany to allow electric scooters / e-rollers on the roads?
Using too much dialogue?
What is the purpose of the yellow wired panels on the IBM 360 Model 20?
Are cells guaranteed to get at least one mitochondrion when they divide?
How to fix cannot find symbol view-model-name-BindingImpl when using two-way databinding in Android
Data Binding class not generatedAndroid RecyclerView Adapter DataBinding - cannot find symbol layoutBindingImplIs there an easy way to add a border to the top and bottom of an Android View?How to change an Android app's name?“cannot resolve symbol R” in Android StudioTwo-Way databinding in EditTextAndroid databinding cannot resolve symbol (gradle 3.0.1)Android two-way databinding cannot get event onCheckedChanged to fireCustom View with Two-Way DatabindingAndroid two way data binding with room table modelsAndroid Databinding for Custom View: 'cannot find symbol' and 'duplicate class found'Convert one-way data binding to two-way using Android Architecture Components
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am implementing Two-Way DataBinding with Android Architecture Components using LiveData
and ViewModel
, but when I build the project it gives
error: cannot find symbol
import package.[layout_name]BindingImpl;
in DataBinderMapperImpl.java
I followed official documentation and looked at SO for answers but none of them had workable solutions.
already tried this one and this one
layout.xml
<data>
<import type="package.ViewModel" /> // this line was added from an answer but didn't work
<variable
name="model"
type="package.ViewModel"/>
</data>
// an input field I want to bind data with
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@=model.email" // if I remove this line, builds fine
android:hint="@string/prompt_email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
Extending my ViewModel
from AndroidViewModel
instead of BaseObservable
as mentioned in documentation
ViewModel.kt
private val email: MutableLiveData<String> by lazy MutableLiveData<String>()
@Bindable // tried to change the return type to String, still no luck
fun getEmail(): LiveData<String>
return email
fun setEmail(email: String)
this.email.value = email
This is how I bind ViewModel
with View
Activity.kt
binding.model = ViewModelProviders.of(this, ViewModelProvider.AndroidViewModelFactory
.getInstance(application))
.get(LoginViewModel::class.java)
What am I missing? Already included all things pre-databinding and if I had replaced ViewModel
in layout
with a data class
and tried to get data from it, that works fine but with @
in layout
EDIT
Okay, so when I expose email
as public
, it compiles and binding works, but I can't make its setter and getter public
, I mean when I try to expose it from its getter and setter, IDE says that these are already private
fun
ctions and cannot be override
n?
How can I make this property expose through fun
ctions?
android android-databinding android-architecture-components android-jetpack
add a comment |
I am implementing Two-Way DataBinding with Android Architecture Components using LiveData
and ViewModel
, but when I build the project it gives
error: cannot find symbol
import package.[layout_name]BindingImpl;
in DataBinderMapperImpl.java
I followed official documentation and looked at SO for answers but none of them had workable solutions.
already tried this one and this one
layout.xml
<data>
<import type="package.ViewModel" /> // this line was added from an answer but didn't work
<variable
name="model"
type="package.ViewModel"/>
</data>
// an input field I want to bind data with
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@=model.email" // if I remove this line, builds fine
android:hint="@string/prompt_email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
Extending my ViewModel
from AndroidViewModel
instead of BaseObservable
as mentioned in documentation
ViewModel.kt
private val email: MutableLiveData<String> by lazy MutableLiveData<String>()
@Bindable // tried to change the return type to String, still no luck
fun getEmail(): LiveData<String>
return email
fun setEmail(email: String)
this.email.value = email
This is how I bind ViewModel
with View
Activity.kt
binding.model = ViewModelProviders.of(this, ViewModelProvider.AndroidViewModelFactory
.getInstance(application))
.get(LoginViewModel::class.java)
What am I missing? Already included all things pre-databinding and if I had replaced ViewModel
in layout
with a data class
and tried to get data from it, that works fine but with @
in layout
EDIT
Okay, so when I expose email
as public
, it compiles and binding works, but I can't make its setter and getter public
, I mean when I try to expose it from its getter and setter, IDE says that these are already private
fun
ctions and cannot be override
n?
How can I make this property expose through fun
ctions?
android android-databinding android-architecture-components android-jetpack
add a comment |
I am implementing Two-Way DataBinding with Android Architecture Components using LiveData
and ViewModel
, but when I build the project it gives
error: cannot find symbol
import package.[layout_name]BindingImpl;
in DataBinderMapperImpl.java
I followed official documentation and looked at SO for answers but none of them had workable solutions.
already tried this one and this one
layout.xml
<data>
<import type="package.ViewModel" /> // this line was added from an answer but didn't work
<variable
name="model"
type="package.ViewModel"/>
</data>
// an input field I want to bind data with
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@=model.email" // if I remove this line, builds fine
android:hint="@string/prompt_email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
Extending my ViewModel
from AndroidViewModel
instead of BaseObservable
as mentioned in documentation
ViewModel.kt
private val email: MutableLiveData<String> by lazy MutableLiveData<String>()
@Bindable // tried to change the return type to String, still no luck
fun getEmail(): LiveData<String>
return email
fun setEmail(email: String)
this.email.value = email
This is how I bind ViewModel
with View
Activity.kt
binding.model = ViewModelProviders.of(this, ViewModelProvider.AndroidViewModelFactory
.getInstance(application))
.get(LoginViewModel::class.java)
What am I missing? Already included all things pre-databinding and if I had replaced ViewModel
in layout
with a data class
and tried to get data from it, that works fine but with @
in layout
EDIT
Okay, so when I expose email
as public
, it compiles and binding works, but I can't make its setter and getter public
, I mean when I try to expose it from its getter and setter, IDE says that these are already private
fun
ctions and cannot be override
n?
How can I make this property expose through fun
ctions?
android android-databinding android-architecture-components android-jetpack
I am implementing Two-Way DataBinding with Android Architecture Components using LiveData
and ViewModel
, but when I build the project it gives
error: cannot find symbol
import package.[layout_name]BindingImpl;
in DataBinderMapperImpl.java
I followed official documentation and looked at SO for answers but none of them had workable solutions.
already tried this one and this one
layout.xml
<data>
<import type="package.ViewModel" /> // this line was added from an answer but didn't work
<variable
name="model"
type="package.ViewModel"/>
</data>
// an input field I want to bind data with
<androidx.appcompat.widget.AppCompatAutoCompleteTextView
android:id="@+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@=model.email" // if I remove this line, builds fine
android:hint="@string/prompt_email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
Extending my ViewModel
from AndroidViewModel
instead of BaseObservable
as mentioned in documentation
ViewModel.kt
private val email: MutableLiveData<String> by lazy MutableLiveData<String>()
@Bindable // tried to change the return type to String, still no luck
fun getEmail(): LiveData<String>
return email
fun setEmail(email: String)
this.email.value = email
This is how I bind ViewModel
with View
Activity.kt
binding.model = ViewModelProviders.of(this, ViewModelProvider.AndroidViewModelFactory
.getInstance(application))
.get(LoginViewModel::class.java)
What am I missing? Already included all things pre-databinding and if I had replaced ViewModel
in layout
with a data class
and tried to get data from it, that works fine but with @
in layout
EDIT
Okay, so when I expose email
as public
, it compiles and binding works, but I can't make its setter and getter public
, I mean when I try to expose it from its getter and setter, IDE says that these are already private
fun
ctions and cannot be override
n?
How can I make this property expose through fun
ctions?
android android-databinding android-architecture-components android-jetpack
android android-databinding android-architecture-components android-jetpack
edited Mar 24 at 16:49
ateebahmed
asked Mar 23 at 21:42
ateebahmedateebahmed
70213
70213
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can use getter of particular variable directly using get()
method to variable (also works for setter too as set(value)
) like below :
@get:Bindable // We make getter method bindable for data-binding
val email = MutableLiveData<String>()
get() // Try to provide getter method like this
return field as LiveData<String>
set(data) // Try to provide setter method like this
if(field.value != data.value) // To avoid infinite loop
field.value = data.value
thanks but for two-way binding to work you have to expose the field asMutableLiveData
and make it default
– ateebahmed
Mar 26 at 19:16
add a comment |
Found the answer on Reddit.
For two-way databinding to work, you have to expose your fields and they should be MutableLiveData
like
val email = MutableLiveData<String>()
since kotlin
already has get
and set
properties, they'll be used by Binding
classes for fields
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318670%2fhow-to-fix-cannot-find-symbol-view-model-name-bindingimpl-when-using-two-way-dat%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use getter of particular variable directly using get()
method to variable (also works for setter too as set(value)
) like below :
@get:Bindable // We make getter method bindable for data-binding
val email = MutableLiveData<String>()
get() // Try to provide getter method like this
return field as LiveData<String>
set(data) // Try to provide setter method like this
if(field.value != data.value) // To avoid infinite loop
field.value = data.value
thanks but for two-way binding to work you have to expose the field asMutableLiveData
and make it default
– ateebahmed
Mar 26 at 19:16
add a comment |
You can use getter of particular variable directly using get()
method to variable (also works for setter too as set(value)
) like below :
@get:Bindable // We make getter method bindable for data-binding
val email = MutableLiveData<String>()
get() // Try to provide getter method like this
return field as LiveData<String>
set(data) // Try to provide setter method like this
if(field.value != data.value) // To avoid infinite loop
field.value = data.value
thanks but for two-way binding to work you have to expose the field asMutableLiveData
and make it default
– ateebahmed
Mar 26 at 19:16
add a comment |
You can use getter of particular variable directly using get()
method to variable (also works for setter too as set(value)
) like below :
@get:Bindable // We make getter method bindable for data-binding
val email = MutableLiveData<String>()
get() // Try to provide getter method like this
return field as LiveData<String>
set(data) // Try to provide setter method like this
if(field.value != data.value) // To avoid infinite loop
field.value = data.value
You can use getter of particular variable directly using get()
method to variable (also works for setter too as set(value)
) like below :
@get:Bindable // We make getter method bindable for data-binding
val email = MutableLiveData<String>()
get() // Try to provide getter method like this
return field as LiveData<String>
set(data) // Try to provide setter method like this
if(field.value != data.value) // To avoid infinite loop
field.value = data.value
answered Mar 26 at 18:47
Jeel VankhedeJeel Vankhede
3,1682521
3,1682521
thanks but for two-way binding to work you have to expose the field asMutableLiveData
and make it default
– ateebahmed
Mar 26 at 19:16
add a comment |
thanks but for two-way binding to work you have to expose the field asMutableLiveData
and make it default
– ateebahmed
Mar 26 at 19:16
thanks but for two-way binding to work you have to expose the field as
MutableLiveData
and make it default– ateebahmed
Mar 26 at 19:16
thanks but for two-way binding to work you have to expose the field as
MutableLiveData
and make it default– ateebahmed
Mar 26 at 19:16
add a comment |
Found the answer on Reddit.
For two-way databinding to work, you have to expose your fields and they should be MutableLiveData
like
val email = MutableLiveData<String>()
since kotlin
already has get
and set
properties, they'll be used by Binding
classes for fields
add a comment |
Found the answer on Reddit.
For two-way databinding to work, you have to expose your fields and they should be MutableLiveData
like
val email = MutableLiveData<String>()
since kotlin
already has get
and set
properties, they'll be used by Binding
classes for fields
add a comment |
Found the answer on Reddit.
For two-way databinding to work, you have to expose your fields and they should be MutableLiveData
like
val email = MutableLiveData<String>()
since kotlin
already has get
and set
properties, they'll be used by Binding
classes for fields
Found the answer on Reddit.
For two-way databinding to work, you have to expose your fields and they should be MutableLiveData
like
val email = MutableLiveData<String>()
since kotlin
already has get
and set
properties, they'll be used by Binding
classes for fields
answered Mar 26 at 19:19
ateebahmedateebahmed
70213
70213
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318670%2fhow-to-fix-cannot-find-symbol-view-model-name-bindingimpl-when-using-two-way-dat%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown