ClassNotFoundException: Didn't find class “android.databinding.DataBinderMapper”

后端 未结 9 1810
长发绾君心
长发绾君心 2020-12-11 14:23

I am using android\'s data binding library for views in a library project

i have added the following line in my root gradle file

classpath \'         


        
相关标签:
9条回答
  • 2020-12-11 14:59

    classpath 'com.android.databinding:dataBinder:1.0-rc1'

    apply plugin: 'com.android.databinding'

    Remove that lib. from gradle.

    0 讨论(0)
  • 2020-12-11 15:04

    Best guess. Get rid of android-apt

    And if there are libraries using apt

    Instead of apt 'lt.mdm.sdd:myLib:1.5.1' use annotationProcessor 'lt.mdm.sdd:myLib:1.5.1'.

    I'm not sure if this will help you, and i have no idea if library it self should be changed.

    It helped me (i was using androidannotations.org older version with apt) at least.

    Update

    And i have no idea why you apply plugin: 'com.android.databinding'? It works without it as well.

    0 讨论(0)
  • 2020-12-11 15:07

    Get inspiration from @Bolein95 say.Because it depend on a library that does not support androidx(no setting databinding=true),Written by a colleague who has left.I copy a few necessary files from his github repo, it work!

    0 讨论(0)
  • 2020-12-11 15:09

    Besides adding the following to build.gradle:

    android {
        dataBinding {
            enabled = true
        }
    }
    

    I also have to add the following dependency:

    dependencies {
        kapt 'com.android.databinding:compiler:3.0.1'
    }
    
    0 讨论(0)
  • 2020-12-11 15:11

    finally i was able to solve this issue. It seems there was a conflict between apt version of the app and library modules.

    upgraded the apt version in the app to

    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    
    0 讨论(0)
  • 2020-12-11 15:13

    The new way of adding DataBinding is by adding on the build.gradle of all your modules:

    android {
    ...
    
      buildFeatures {
        dataBinding true
      }
    }
    

    Don't forget to add also the kotlin-kapt plugin at the top:

    plugins {
      ...
      id 'kotlin-kapt'
    }
    
    0 讨论(0)
提交回复
热议问题