java.lang.NoClassDefFoundError: android.databinding.DataBinderMapperImpl when running Espresso tests

前端 未结 5 1303
刺人心
刺人心 2021-01-04 13:04

Data binding setup:

apply plugin: \'kotlin-kapt\'

android {
    dataBinding {
        enabled = true
    }
}

dependencies {
    kapt \"com.android.databind         


        
5条回答
  •  -上瘾入骨i
    2021-01-04 13:20

    I have the same this issue, and fixed by adding

    kapt {
        generateStubs = true
    }
    

    in build.gradle app (all module if using dataBinding)

    apply plugin: 'kotlin-kapt'
    
    android {
    ...
        dataBinding {
            enabled = true
        }
    }
    
    kapt {
        generateStubs = true
    }
    
    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        ...
        implementation "androidx.core:core-ktx:+"
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        kapt "com.android.databinding:compiler:$android_plugin_version"
    
    }
    

    In build.gradle project

    buildscript {
        ext.kotlin_version = '1.3.70'
        ext.android_plugin_version = '3.5.2'
        repositories {
            google()
            jcenter()
    
        }
        dependencies {
            classpath "com.android.tools.build:gradle:$android_plugin_version"
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        }
    }
    

提交回复
热议问题