Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Data Binding: missing DataBinderMapper class

java.lang.NoClassDefFoundError: android.databinding.DataBinderMapper
        at android.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:31)
        at com.example.MainActivity.onCreate(MainActivity.java:13)
        at android.app.Activity.performCreate(Activity.java:5231)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
        at android.app.ActivityThread.access$800(ActivityThread.java:135)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:136)
        at android.app.ActivityThread.main(ActivityThread.java:5001)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:515)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
        at dalvik.system.NativeStart.main(Native Method)

I hope this is a bug, does anyone face a similar problem? I unzipped classes.jar under the exploded-arr folder, but couldn't find the DataBinderMapper class.

Any workarounds / fixes would be appreciated.

like image 563
Ragunath Jawahar Avatar asked May 31 '15 06:05

Ragunath Jawahar


2 Answers

Make sure that ALL your modules that use DataBinding have it enabled. This was the reason I got that exception.

android {
    ...
    dataBinding {
        enabled = true
    }
}
like image 129
madhu527 Avatar answered Nov 13 '22 20:11

madhu527


You should include the android-apt plugin in your build.gradle in order to generate the android.databinding.DataBinderMapper class.

In your project build.gradle:

dependencies {
        classpath 'com.android.tools.build:gradle:1.3.1'
        classpath 'com.android.databinding:dataBinder:1.0-rc2'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
//.... more
}

In each module build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
apply plugin: 'com.neenbedankt.android-apt'

More information

like image 25
Kavinda Gayashan Avatar answered Nov 13 '22 22:11

Kavinda Gayashan