简体   繁体   中英

Greendao and NoClassDefFoundError

In the process of using greendao, when the initialization time, being given:

java.lang.NoClassDefFoundError: org.greenrobot.greendao.query.WhereCollector

This exception did not occur during the compilation process, and the actual error code crashed directly at run time as follows:

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)

在此处输入图片说明

Try this:

-Add this dependency compile 'com.android.support:multidex:1.0.1'

-Add multiDexEnabled = true in your build.gradle app config.

-Change your extend Application "MyAplication.APPAplication" to MultiDexApplication .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM