本文介绍了ClassNotFoundException:找不到类"android.databinding.DataBinderMapper";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用android的数据绑定库获取库项目中的视图

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

我已在我的根gradle文件中添加了以下行

i have added the following line in my root gradle file

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

并启用了模块gradle文件中下面给出的dataBinding

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

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

我已经在我的图书馆项目中启用了multiDex以及正在使用该库的主机应用程序中但是在启动库的活动时,我得到了堆栈错误信息

i have enabled the multiDex in my library projectas well as in the host app which is using this librarybut 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

推荐答案

最后,我能够解决此问题.似乎该应用程序的apt版本与库模块之间存在冲突.

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

将应用程序中的apt版本升级到

upgraded the apt version in the app to

classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'

这篇关于ClassNotFoundException:找不到类"android.databinding.DataBinderMapper";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 14:08