本文介绍了Android 数据绑定:缺少 DataBinderMapper 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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)

我希望这是一个错误,有人遇到过类似的问题吗?我将 classes.jar 解压到 exploded-arr 文件夹下,但找不到 DataBinderMapper 类.

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.

推荐答案

确保所有使用 DataBinding 的模块都启用了它.这就是我得到那个例外的原因.

android {
    ...
    dataBinding {
        enabled = true
    }
}

这篇关于Android 数据绑定:缺少 DataBinderMapper 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 00:20