2017-05-04 55 views
0

在使用greendao,當初始化時間的過程,報錯:Greendao和NoClassDefFoundError的

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) 

enter image description here

+0

你有proguard激活? – pablogupi

回答

1

試試這個:

- 添加此依賴項compile 'com.android.support:multidex:1.0.1'

-Add multiDexEnabled = true在您的build.gradle應用程序配置中。

- 將您的擴展應用程序「MyAplication.APPAplication」更改爲MultiDexApplication

+0

非常感謝您的幫助,問題已解決! – Vicent

+1

不客氣!請標記爲正確的答案 – pablogupi

+0

我不知道如何標記,你能告訴我嗎? – Vicent