本文介绍了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
在 explosive-arr
文件夹下,但找不到 DataBinderMapper
class。
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.
推荐答案
您应该在build.gradle中包含android-apt插件,以生成 android.databinding.DataBinderMapper
类。
You should include the android-apt plugin in your build.gradle in order to generate the android.databinding.DataBinderMapper
class.
在您的项目build.gradle中:
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
}
在每个模块build.gradle:
In each module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
apply plugin: 'com.neenbedankt.android-apt'
这篇关于Android数据绑定:缺少DataBinderMapper类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!