Android 4.4.2上的Android NoClassDefFoundError

时间:2018-07-18 06:43:00

标签: android android-4.4-kitkat

当我尝试在Android 4.4.2上运行我的应用程序时,出现此错误:

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: my.package, PID: 24775
              java.lang.NoClassDefFoundError: my/package/models/Transaction
                  at java.lang.Class.getDeclaredFields(Native Method)
                  at java.lang.Class.getDeclaredFields(Class.java:610)
                  at com.activeandroid.util.ReflectionUtils.getDeclaredColumnFields(ReflectionUtils.java:73)
                  at com.activeandroid.TableInfo.<init>(TableInfo.java:66)
                  at com.activeandroid.ModelInfo.loadModelFromMetaData(ModelInfo.java:101)
                  at com.activeandroid.ModelInfo.<init>(ModelInfo.java:61)
                  at com.activeandroid.Cache.initialize(Cache.java:66)
                  at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:44)
                  at com.activeandroid.ActiveAndroid.initialize(ActiveAndroid.java:34)
                  at com.activeandroid.content.ContentProvider.onCreate(ContentProvider.java:39)
                  at android.content.ContentProvider.attachInfo(ContentProvider.java:1591)
                  at android.content.ContentProvider.attachInfo(ContentProvider.java:1562)
                  at android.app.ActivityThread.installProvider(ActivityThread.java:5233)
                  at android.app.ActivityThread.installContentProviders(ActivityThread.java:4827)
                  at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
                  at android.app.ActivityThread.access$1600(ActivityThread.java:174)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1367)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:146)
                  at android.app.ActivityThread.main(ActivityThread.java:5593)
                  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:1283)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
                  at dalvik.system.NativeStart.main(Native Method)
               Caused by: java.lang.ClassNotFoundException: Didn't find class "my.package.models.Transaction" on path: DexPathList[[zip file "/data/app/my.package-1.apk"],nativeLibraryDirectories=[/data/app-lib/my.package-1, /vendor/lib, /system/lib]]
                  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:457)

但是,对于Android 5.0及更高版本,它可以正常运行而没有任何错误。

原因是什么,我该如何解决?

注意:StackOverflow也有类似的问题,但没有任何答案。

2 个答案:

答案 0 :(得分:2)

答案 1 :(得分:0)

尝试一下

只需禁用即时运行,请转到

  

文件->设置->构建,执行,部署->即时运行->   取消选中即时运行复选框

运行一次您的应用。