美文网首页
DataBinding - 踩坑记

DataBinding - 踩坑记

作者: Singal11 | 来源:发表于2019-03-13 17:19 被阅读0次

    1. Didn't find class "android.databinding.DataBinderMapperImpl"

    项目加入dataBinding之后编译运行,在Activity页面跳转时报了个错误:

    java.lang.NoClassDefFoundError: Failed resolution of: Landroid/databinding/DataBinderMapperImpl;
            at android.databinding.DataBindingUtil.<clinit>(DataBindingUtil.java:32)
            at com.xxx.gui.BaseActivity.initViewDataBinding(BaseActivity.java:151)
            at com.xxx.gui.BaseActivity.onCreate(BaseActivity.java:79)
            at android.app.Activity.performCreate(Activity.java:6222)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2407)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5280)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758)
         Caused by: java.lang.ClassNotFoundException: Didn't find class "android.databinding.DataBinderMapperImpl" on path: DexPathList[[zip file "/data/app/com.xxx.xxx-1/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-1/lib/arm, /vendor/lib, /system/lib]]
            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:32) 
            at com.xxx.gui.BaseActivity.initViewDataBinding(BaseActivity.java:151) 
            at com.xxx.gui.BaseActivity.onCreate(BaseActivity.java:79) 
            at android.app.Activity.performCreate(Activity.java:6222) 
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295) 
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2407) 
            at android.app.ActivityThread.access$800(ActivityThread.java:151) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319) 
            at android.os.Handler.dispatchMessage(Handler.java:102) 
            at android.os.Looper.loop(Looper.java:135) 
            at android.app.ActivityThread.main(ActivityThread.java:5280) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at java.lang.reflect.Method.invoke(Method.java:372) 
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:963) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:758) 
            Suppressed: java.lang.ClassNotFoundException: android.databinding.DataBinderMapperImpl
            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)
                    ... 17 more
         Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
    

    几番搜索之后发现是gradle配置问题,由于项目中包含了多个子module,某个Activity所在的module没有配置dataBinding导致的。

     dataBinding {
            enabled = true
     }
    

    相关文章

      网友评论

          本文标题:DataBinding - 踩坑记

          本文链接:https://www.haomeiwen.com/subject/ogibpqtx.html