我一直在Android SDK版本19上开发app并在模拟器/手机4.4.2上运行它没有问题。
然后我将minSdkVersion设置为8(在build.gradle和AndroidManifest.xml中),成功重建,但在使用Android 2.3.7在模拟器上启动时,我得到:
02-09 03:08:48.383 1546-1546/? E/AndroidRuntime FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{cz.xxx.appname/cz.xxx.appname.ui.HomeActivity}: java.lang.ClassNotFoundException: cz.xxx.appname.ui.HomeActivity in loader dalvik.system.PathClassLoader[/data/app/cz.xxx.appname-2.apk]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1569)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: cz.xxx.appname.ui.HomeActivity in loader dalvik.system.PathClassLoader[/data/app/cz.xxx.appname-2.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
at android.app.ActivityThread.access$1500(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3683)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
应用程序始终在启动时崩溃。相同的构建在4.2.2上成功运行。
你知道导致这个问题的原因吗?
谢谢, endokr
答案 0 :(得分:0)
问题可能是,您在活动布局中使用的组件不存在于旧版本的API(在您的情况下为2.3.6)中,例如切换按钮,因此请检查活动布局中的组件。