Greendao 和 NoClassDefFoundError
Greendao and NoClassDefFoundError
在使用greendao的过程中,初始化的时候,报错:
java.lang.NoClassDefFoundError: org.greenrobot.greendao.query.WhereCollector
编译过程中并没有出现这个异常,实际错误代码在运行时直接崩溃如下:
AndroidRuntime: FATAL EXCEPTION: main
Process: com.luckytry.hybrid.mainapplication, PID: 4274
java.lang.NoClassDefFoundError: org.greenrobot.greendao.query.WhereCollector
at org.greenrobot.greendao.query.QueryBuilder.<init>(QueryBuilder.java:85)
at org.greenrobot.greendao.query.QueryBuilder.<init>(QueryBuilder.java:77)
at org.greenrobot.greendao.query.QueryBuilder.internalCreate(QueryBuilder.java:73)
at org.greenrobot.greendao.AbstractDao.queryBuilder(AbstractDao.java:793)
at com.luckytry.luckylibrary.MyAplication.APPAplication.initData(APPAplication.java:132)
at com.luckytry.luckylibrary.MyAplication.APPAplication.initDB(APPAplication.java:117)
at com.luckytry.luckylibrary.MyAplication.APPAplication.onCreate(APPAplication.java:39)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1009)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4655)
at android.app.ActivityThread.access00(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5356)
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:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)
at dalvik.system.NativeStart.main(Native Method)
试试这个:
-添加这个依赖compile 'com.android.support:multidex:1.0.1'
-在您的 build.gradle 应用配置中添加 multiDexEnabled = true
。
-将您的扩展应用程序 "MyAplication.APPAplication" 更改为 MultiDexApplication
。
在使用greendao的过程中,初始化的时候,报错:
java.lang.NoClassDefFoundError: org.greenrobot.greendao.query.WhereCollector
编译过程中并没有出现这个异常,实际错误代码在运行时直接崩溃如下:
AndroidRuntime: FATAL EXCEPTION: main
Process: com.luckytry.hybrid.mainapplication, PID: 4274
java.lang.NoClassDefFoundError: org.greenrobot.greendao.query.WhereCollector
at org.greenrobot.greendao.query.QueryBuilder.<init>(QueryBuilder.java:85)
at org.greenrobot.greendao.query.QueryBuilder.<init>(QueryBuilder.java:77)
at org.greenrobot.greendao.query.QueryBuilder.internalCreate(QueryBuilder.java:73)
at org.greenrobot.greendao.AbstractDao.queryBuilder(AbstractDao.java:793)
at com.luckytry.luckylibrary.MyAplication.APPAplication.initData(APPAplication.java:132)
at com.luckytry.luckylibrary.MyAplication.APPAplication.initDB(APPAplication.java:117)
at com.luckytry.luckylibrary.MyAplication.APPAplication.onCreate(APPAplication.java:39)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1009)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4655)
at android.app.ActivityThread.access00(ActivityThread.java:143)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1322)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5356)
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:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)
at dalvik.system.NativeStart.main(Native Method)
试试这个:
-添加这个依赖compile 'com.android.support:multidex:1.0.1'
-在您的 build.gradle 应用配置中添加 multiDexEnabled = true
。
-将您的扩展应用程序 "MyAplication.APPAplication" 更改为 MultiDexApplication
。