#greendao#NoClassDefFoundError: 男娘i 2022-06-16 03:50 177阅读 0赞 今天在调试项目的时候,项目编译都正常如初,但是运行的时候直接崩掉了,异常如下: java.lang.NoClassDefFoundError: org.greenrobot.greendao.query.WhereCollector at org.greenrobot.greendao.query.QueryBuilder.<init>(QueryBuilder.java:85) 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) 然后我花了一个下午时间,通过百度、QQ群、CSDN,github、stackoverflow等等,终于解决了步骤如下: 1. 添加依赖 compile 'com.android.support:multidex:1.0.1' 1. 修改build.gradle文件 android { ... defaultConfig { ... multiDexEnabled true ... } ... } 1. 修改Application <application android:name="MultiDexApplication" android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:theme="@style/AppTheme" android:windowSoftInputMode="adjustPan"> //如果有自定义的Application,就修改继承关系 public class APPAplication extends MultiDexApplication { } 然后再次运行就解决这个异常了! 感谢老外的“堆栈溢出”——[stackoverflow][]! [stackoverflow]: https://stackoverflow.com/questions/43776165/greendao-and-noclassdeffounderror
还没有评论,来说两句吧...