在 Android 4.4 (19) 添加 Ion 库后出现 ClassNotFoundException

ClassNotFoundException after adding Ion library in Android 4.4 (19)

将 Ion 库添加到我的项目后,我无法在 Android 4.4 中启动我的应用程序,更高版本的一切正常。

E/AndroidRuntime: FATAL EXCEPTION: main
              Process: com.swe.gruppe4.mockup2, PID: 3281
              java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.swe.gruppe4.mockup2/com.swe.gruppe4.mockup2.LoginActivity}: java.lang.ClassNotFoundException: Didn't find class "com.swe.gruppe4.mockup2.LoginActivity" on path: DexPathList[[zip file "/data/app/com.swe.gruppe4.mockup2-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.swe.gruppe4.mockup2-2, /vendor/lib, /system/lib]]
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
                  at android.app.ActivityThread.access0(ActivityThread.java:135)
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
                  at android.os.Handler.dispatchMessage(Handler.java:102)
                  at android.os.Looper.loop(Looper.java:136)
                  at android.app.ActivityThread.main(ActivityThread.java:5017)
                  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:779)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                  at dalvik.system.NativeStart.main(Native Method)
               Caused by: java.lang.ClassNotFoundException: Didn't find class "com.swe.gruppe4.mockup2.LoginActivity" on path: DexPathList[[zip file "/data/app/com.swe.gruppe4.mockup2-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.swe.gruppe4.mockup2-2, /vendor/lib, /system/lib]]
                  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
                  at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
                  at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
                  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245) 
                  at android.app.ActivityThread.access0(ActivityThread.java:135) 
                  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196) 
                  at android.os.Handler.dispatchMessage(Handler.java:102) 
                  at android.os.Looper.loop(Looper.java:136) 
                  at android.app.ActivityThread.main(ActivityThread.java:5017) 
                  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:779) 
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595) 
                  at dalvik.system.NativeStart.main(Native Method) 
Application terminated.

我通过应用程序的 build.gradle 添加了 Ion,正如 github、compile 'com.koushikdutta.ion:ion:2.+' 上所述。

如前所述,在更高的 Android 版本上它工作正常。 它也适用于一个完全干净的项目,只需添加 Ion

我现在自己修好了。 我创建了一个具有相同包名的新项目,并将 app 文件夹完全复制到新项目中,在那里工作正常。奇怪!