How to start using view binding //Android Kotlin Dev Diary

First, open your app/build.gradle file Inside the android{} block of app/build.gradle, add the following: buildFeatures { viewBinding = true } Sync project with gradle files. In your activity or fragment, define the following class-wide property:

Replace the FragmentorActivityNameBinding above with the appropriate binding class name. Tip: The binding class name is based on the […]

Read More

Exception: No signature of method android() is applicable for argument types, Build Gradle // Dev Diary

Today I wanted to make a data class a Parcelable so that I could pass it as an argument in Navigation component. Parcelables, though better in performance than Serializables, take more time to implement! To help us out, there’s a “kotlin-parcelize” plugin that can generate the boilerplate code for us. There were issues though. After […]

Read More

Fix coroutine error: Cannot access database on the main thread // Android Dev Diary

As I was running a test for a ViewModel function, I encountered the following error: […] Main Thread @coroutine java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time. I think it may be caused by the viewModelScope from viewModelScope.launch {} being used by […]

Read More