https://kotlinlang.org logo
Join SlackCommunities
Powered by
# android-databinding
  • p

    pererikbergman

    09/06/2018, 5:29 PM
    I tried that as well, same error.
  • p

    pererikbergman

    09/06/2018, 5:30 PM
    I’m using AS 3.1.4
  • p

    pererikbergman

    09/06/2018, 5:45 PM
    Yes, I actually found the error… kinda embarrassing 🙂 I had forgotten to add: apply plugin: ‘kotlin-kapt’ Thanks for the input 🙂
  • s

    Smorg

    01/05/2019, 6:30 AM
    Hi, I have a method with the signature below:
    fun function(paramFunction: (() -> Entity)?)
    I am trying to pass the specified
    paramFunction
    as null through databinding:
    android:onClick="@{() -> viewModel.function(null)}"
    But I got an exception during compilation:
    Copy code
    [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.
    ****/ data binding error ****msg:cannot find method function(java.lang.Object) in class…
    Does anyone have an idea how I can resolve this please?
    g
    d
    • 3
    • 2
  • g

    Geert

    04/25/2019, 2:55 PM
    I suddenly get this error (since I added realm), does someone know how to fix this? UPDATE: Hmm had to apply plugin before kapt…
  • s

    Steph Carter

    05/28/2019, 10:07 PM
    Is there a way to exclude a view from being data-bound? I need the ID to arrange the view, but I don’t need to reference it programmatically.
    👍 1
    p
    o
    • 3
    • 3
  • w

    Will Shelor

    06/26/2019, 7:27 PM
    I want to create an "inflateWhen" BindingAdapter and attach it to a viewstub to have it inflate when a boolean value is true. However, the BindingAdapter keeps trying to operate on the root view of the viewstub, causing it to fail to compile. Is there any way to do this as a bindingadapter rather than having to do it programmatically in the activity?
    p
    • 2
    • 1
  • v

    voben

    12/30/2019, 9:23 PM
    How do I trigger a button click in my layout file? I have this onClick on my Button xml. But I can’t create an instance on my person class because it keeps saying
    Cannot find Identifier Person
    . How do I resolve this?
    Copy code
    android:onClick="@{() -> viewModel.doSomething(Person())}"
    m
    r
    +2
    • 5
    • 4
  • k

    kagomez

    01/25/2020, 8:29 PM
    Hey guys 😄 Got a question for you; have you ever think about anti-patterns and patterns by using android databinding?
    a
    m
    o
    • 4
    • 9
  • y

    yodgor777

    02/29/2020, 9:21 AM
    guys I hope all of you doing great anyone worked with data binding with https://stackoverflow.com/questions/60449644/error-kapt-an-exception-occurred-android-databinding-tool-util-loggederrorex/60452796?noredirect=1#comment106950354_60452796 I am getting following errors I have post my question stackoverflow I did not get any suitable answer I have done as suggested answer but I am still getting error any help will be vital for me
    a
    k
    • 3
    • 3
  • i

    Ivann Ruiz

    03/22/2020, 9:51 PM
    Keep seeing this problem with databinding, been searching on Google for over an hour now... curious if anybody has seen this error before. Any help is much appreciated. I have the
    kotlin-kapt
    plugin and all btw.
    Copy code
    error: package javax.annotation does not exist
    import javax.annotation.Generated;
    It is a Kotlin multiplatform project, below are the versions for the libraries i'm using:
    Copy code
    kotlinVersion = "1.3.70"
    serialization = "0.20.0"
    coroutines = "1.3.5"
    ktor = "1.3.2"
    kodein = "6.5.3"
    moko = "0.6.0"
    navigation = "2.3.0-alpha04"
    a
    • 2
    • 3
  • m

    Merthan Erdem

    04/03/2020, 1:35 PM
    Would love some feedback on this MVVM/Databinding base class for Fragments/Activities, let me know if anything could be improved https://link.medium.com/vaiuq6mej5
    e
    m
    • 3
    • 2
  • e

    emmano

    04/21/2020, 6:55 PM
    You all probably know this, but if you are storing your binding in your
    Fragment
    , you must set it to
    null
    in
    onDestroyView()
    , otherwise you will leak the
    Views
    that the binding holds.
    🙌 4
    • 1
    • 1
  • r

    Rahul Singhal

    05/01/2020, 6:37 PM
    Copy code
    <attr name="onClick" format="string" />
    
    android:onClick="@{() -> onClickEvent.invoke()}"
    Please help me to understand how onClick accept the lamda function . how this () -> onClickEvent.invoke() convert to string Thread in Slack Conversation
  • r

    Reprator

    05/08/2020, 2:51 AM
    Hi Mates, i got a weird issue, please assist me in this one
  • l

    Leon johnson

    05/12/2020, 11:59 AM
    Hey guys, I’m working with a view model in my app and I noticed that each fragment that I use a view model provider in the data in the view model is null. But in the previous fragment I would update a field. Ex: I have a fragment that takes in an email and password and stores that into the view model. Then I have another fragment that needs to access the email and password from the view model in order to create an user account. But when I try to access it, the email and password are null
    a
    • 2
    • 5
  • l

    Leon johnson

    05/13/2020, 7:50 PM
    Hey guys I really need help I am using Kotlin to create an Android App. The problem I am having is I’m trying to use a ViewModel to create an user in Firebase. After the user is created, something should be returned to the UI Fragment to let the fragment know to move forward to the next line of execution. The trouble I’m having is Firebase operations are done asynchronously, so there’s no way for me the front end to know the operation is done executing in the view model. Is there a way to create a callback or fix this?
    google 1
    stackoverflow 1
    i
    • 2
    • 1
  • l

    Leon johnson

    05/15/2020, 3:28 PM
    I'm trying to create an user and store into my firebase database using livedata observer. When I start the app up and run it the first time, the authentication works. But when I log the user out and try to create another user my app crashes. Any idea why this may be?
  • k

    karandeep singh

    06/01/2020, 5:11 PM
    Hi, I am using gradlePluginVersion 3.6.2, still I am getting warning that Databinding is non incremental. I have android.databinding.incremental=true as well. Any idea what could be the issue here?
    d
    • 2
    • 4
  • k

    karandeep singh

    06/22/2020, 3:52 PM
    Hi, does anyone have idea how to import multiple R classes in xml? I am getting
    Cannot import same alias twice.
    m
    • 2
    • 2
  • d

    David Miguel

    07/08/2020, 1:49 PM
    I’ve created a custom view that is using data binding. When I use the custom view in a layout it works perfectly in a device, but I cannot manage to have a working layout preview. I always get the following exception:
    ClassNotFoundException: androidx.databinding.DataBinderMapperImpl
    any idea how to solve it?
    a
    • 2
    • 2
  • j

    Jarosław Michalik

    09/02/2020, 6:43 AM
    Hey all! I did weird thing and described process - attempt to test data binding generated code. I wonder what you think about it :D https://kotlintesting.com/testing-generated-databinding-code/
    👀 1
    c
    • 2
    • 1
  • r

    R Brian Amesbury

    10/27/2020, 4:53 PM
    I am trying to add view binding to a second module in my project like this
    Copy code
    android {
    
        lintOptions {
            isWarningsAsErrors = true
            isAbortOnError = true
        }
    
        buildFeatures {
            viewBinding = true
        }
    
    }
    I have a common android gradle file that configures alot of other android stuff which allows this android block to be really small. i keep getting this error
    Copy code
    e: /Users/amesbub/workspace/android/components/build.gradle.kts:40:5: Unresolved reference: buildFeatures
    e: /Users/amesbub/workspace/android/components/build.gradle.kts:41:9: Unresolved reference: viewBinding
    I am applying
    Copy code
    id("com.android.library")
  • r

    R Brian Amesbury

    10/27/2020, 4:53 PM
    any thoughts on what might be wrong
  • c

    Christopher Elías

    12/10/2020, 12:55 PM
    Hello, well I also have modules that work with DataBinding the general config is this:
    Copy code
    apply plugin: 'com.android.library'
    apply plugin: 'kotlin-android'
    apply plugin: 'kotlin-parcelize'
    apply plugin: 'kotlin-kapt' //THIS IS IMPORTANT FOR GENERATE THE CLASSES FROM DATABINDING
    
    android {
    
        defaultConfig {
            ....
        }
    
        ...
    
        kotlinOptions.jvmTarget = "1.8"
    }
    
    dependencies {
        ...
    }
    Make sure you add the
    'kotlin-kapt'
    plugin at the top and with that you should be running the project without problems
  • n

    note8g2018

    03/03/2021, 10:09 AM
    Please tell Google to update the code lab for jetpack compose https://developer.android.com/courses/pathways/compose It is not working now Because the code is old and there are many huge changes in the framework jetpack compose Google should update the code
    w
    • 2
    • 1
  • y

    yassir kazzoune

    03/10/2021, 7:50 PM
    can i use the same id views in different layouts when using Databinding? i.e.:
    mainBidning.myId , dummyBinding.myId
    w
    • 2
    • 1
  • b

    Brady Aiello

    05/06/2021, 11:59 PM
    Is it just me, or is
    viewBinding
    not working at all in the latest canary build?
    ➕ 1
    k
    • 2
    • 1
  • g

    gzhenjin

    07/22/2021, 9:13 AM
    If I use jetpack compose ,then I dont need databinding ?
    g
    • 2
    • 1
  • a

    akshay

    08/15/2021, 5:37 AM
    Anyone worked with MotionLayout? How can we set the 
    CustomAttribute
     text using DataBinding?