Android build error when using data binding with realm object
See original GitHub issueHi, i have this problem.
If i have a class that inherits RealmObject
import io.realm.kotlin.types.RealmObject
class User: RealmObject {
var name: String = ""
And i try to make it as live data
class LoginViewModel : ViewModel() {
val user = MutableLiveData<User>()
And i use data binding to display its value somewhere in my layout
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{viewModel.user.name}"
tools:text="hi User"/>
I will get this error when i try to build the app
/path/to/my/android_app/app/build/generated/source/kapt/debug/com/my_app/android/databinding/FragmentLoginBindingImpl.java:215: error: cannot access User
private boolean onChangeViewModelUser(androidx.lifecycle.MutableLiveData<com.my_app.android.database.models.User> ViewModelUser, int fieldId) {
^
bad class file: /path/to/my/android_app/app/build/tmp/kotlin-classes/debug/com/my_app/android/database/models/User.class
undeclared type variable: T
Please remove or make sure it appears in the correct subdirectory of the classpath.
Any insight on this would be appreciated, Thanks!
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Realm and Android DataBinding - Stack Overflow
The problem seems to be the fact that i use databinding and Realm in the same application. realm. commitTransaction(); I don't understant what ......
Read more >Confusing/missing error messages using Realm and data ...
Try to build and observe that you only get errors that data bindings were not generated (e.g. Error:(3, 38) error: package com.example.android.databinding ......
Read more >Applying Data Binding for Views | CodePath Android Cliffnotes
If you see an error message such as cannot resolve symbol 'ActivityMainBinding' then this means that the data binding auto-generated class has not...
Read more >3 Methods for Solving Android Data Binding Errors - Atomic Spin
1. View All of the Build Output · 2. Fall Back to the Old Data Binding Compiler Temporarily · 3. Invalidate Caches.
Read more >Realm: Create reactive mobile apps in a fraction of the time
(Android's UI thread is a Looper.) This means the Realm instance will be periodically updated to the latest version. This lets you keep...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, I see. I was using version
1.0.0
, but once I updated it to1.0.1
I can now build the app successfully. As for reproducing the error you can easily reproduce it by downgrading the realm to version1.0.0
in yourKotlinCoroutineswithArchitectureComponentsLiveDataViewModelLifecycle
app.Thanks for your help @nhachicha!
Duplicate of #901