当我尝试在Android 4.4.2上运行现有应用程序(使用Android Studio 3.1.3)时,该应用程序未运行并显示此错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: my.project, PID: 9428
java.lang.NoClassDefFoundError: uz/uno/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.project.models.Transaction" on path: DexPathList[[zip file "/data/app/my.project-5.apk"],nativeLibraryDirectories=[/data/app-lib/my.project-5, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
请注意以下异常:
Caused by: java.lang.ClassNotFoundException: Didn't find class "my.project.models.Transaction" on path: DexPathList[[zip file "/data/app/my.project-5.apk"],nativeLibraryDirectories=[/data/app-lib/my.project-5, /vendor/lib, /system/lib]]
我发现,每次尝试运行并崩溃时,异常中的数字都会增加my.project-5
。 (第一次是my.project-1
,然后是my.project-2
,依此类推。)
问题出在哪里,如何解决此错误?
注意:android 4.3上也会发生此错误。但是,对于android 5.0及更高版本,它运行良好。
编辑:答案 经过研究,我在这里找到了答案:
答案 0 :(得分:0)
我认为您与一些至少需要android 5.0的代码存在冲突,但是您在4.4.2中运行。 请参见以下文档:https://developer.android.com/training/basics/supporting-devices/platforms和此处:https://developer.android.com/guide/practices/compatibility
发布代码,以便我们为您提供更好的帮助。