Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ClassNotFoundException: Didn't find class "android.databinding.DataBinderMapper"

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 'com.android.databinding:dataBinder:1.0-rc1' 

and have enabled the dataBinding as given below in module's gradle file

apply plugin: 'com.android.databinding' ... ... android { ....   dataBinding {       enabled = true   } } 

i have enabled the multiDex in my library project as well as in the host app which is using this library but i get this stack trace of error while launching the library's activity

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/databinding/DataBinderMapper;     at android.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:31)     at sdk.ui.activities.MyActivity.onCreate(MyActivity.java:76)     at android.app.Activity.performCreate(Activity.java:6280)     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)     at android.app.ActivityThread.-wrap11(ActivityThread.java)     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)     at android.os.Handler.dispatchMessage(Handler.java:111)     at android.os.Looper.loop(Looper.java:207)     at android.app.ActivityThread.main(ActivityThread.java:5763)     at java.lang.reflect.Method.invoke(Native Method)     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749) Caused by: java.lang.ClassNotFoundException: Didn't find class "android.databinding.DataBinderMapper" on path: DexPathList[[zip file "/data/app/testApp.dev-1/base.apk"],nativeLibraryDirectories=[/data/app/testApp.dev-1/lib/arm64, /data/app/testApp.dev-1/base.apk!/lib/arm64-v8a, /vendor/lib64, /system/lib64]]     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)     at android.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:31)      at sdk.ui.activities.MyActivity.onCreate(MyActivity.java:76)      at android.app.Activity.performCreate(Activity.java:6280)      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1116)      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2534)      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2647)      at android.app.ActivityThread.-wrap11(ActivityThread.java)      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1502)      at android.os.Handler.dispatchMessage(Handler.java:111)      at android.os.Looper.loop(Looper.java:207)      at android.app.ActivityThread.main(ActivityThread.java:5763)      at java.lang.reflect.Method.invoke(Native Method)      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:749)  Suppressed: java.lang.ClassNotFoundException: android.databinding.DataBinderMapper     at java.lang.Class.classForName(Native Method)     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)         ... 15 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available 
like image 387
A. kanojia Avatar asked Nov 30 '16 07:11

A. kanojia


1 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 162
Bolein95 Avatar answered Sep 24 '22 01:09

Bolein95