java.lang.RuntimeException
05-21 10:03:03.916: E/AndroidRuntime(18573): FATAL EXCEPTION: main
05-21 10:03:03.916: E/AndroidRuntime(18573): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.tomato/com.example.alarmtest.AppStart}: java.lang.ClassNotFoundException: com.example.alarmtest.AppStart
05-21 10:03:03.916: E/AndroidRuntime(18573): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
05-21 10:03:03.916: E/AndroidRuntime(18573): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
05-21 10:03:03.916: E/AndroidRuntime(18573): at android.app.ActivityThread.access$600(ActivityThread.java:139)
05-21 10:03:03.916: E/AndroidRuntime(18573): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
05-21 10:03:03.916: E/AndroidRuntime(18573): at android.os.Handler.dispatchMessage(Handler.java:99)
05-21 10:03:03.916: E/AndroidRuntime(18573): at android.os.Looper.loop(Looper.java:154)
05-21 10:03:03.916: E/AndroidRuntime(18573): at android.app.ActivityThread.main(ActivityThread.java:4944)
05-21 10:03:03.916: E/AndroidRuntime(18573): at java.lang.reflect.Method.invokeNative(Native Method)
05-21 10:03:03.916: E/AndroidRuntime(18573): at java.lang.reflect.Method.invoke(Method.java:511)
05-21 10:03:03.916: E/AndroidRuntime(18573): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-21 10:03:03.916: E/AndroidRuntime(18573): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-21 10:03:03.916: E/AndroidRuntime(18573): at dalvik.system.NativeStart.main(Native Method)
05-21 10:03:03.916: E/AndroidRuntime(18573): Caused by: java.lang.ClassNotFoundException: com.example.alarmtest.AppStart
05-21 10:03:03.916: E/AndroidRuntime(18573): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-21 10:03:03.916: E/AndroidRuntime(18573): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-21 10:03:03.916: E/AndroidRuntime(18573): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-21 10:03:03.916: E/AndroidRuntime(18573): at android.app.Instrumentation.newActivity(Instrumentation.java:1039)
05-21 10:03:03.916: E/AndroidRuntime(18573): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
操作方法
- 01
一般出现这个问题主要是没有在项目的androidManifest.xml里注册使用activity,主要就是这句: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.tomato/com.example.alarmtest.AppStart}: java.lang.ClassNotFoundException: com.example.alarmtest.AppStart
- 02
上面它已经就说,你没有实例化com.example.tomato/com.example.alarmtest.AppStart,tomato是项目名字,AppStart是没有实例化的activity。这就明白了,检查这下,注册 <activity android:name="com.example.tomato.AppStart"/>。
- 03
但有时你发觉你已经注册,这时你要仔细检查,看看是不是包名写错了,仔细排查错误。就能解决了。