在使用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.access$1800(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)
答案 0 :(得分:1)
试试这个:
- 添加此依赖项compile 'com.android.support:multidex:1.0.1'
- 在build.gradle应用配置中添加multiDexEnabled = true
。
- 更改您的扩展应用程序&#34; MyAplication.APPAplication&#34;到MultiDexApplication
。