Thursday, June 20, 2013

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

Problem on Java Build Path again...! similar to the case of Unexpected namespace prefix "xmlns" found for tag fragment on xmlns:map="http://schemas.android.com/apk/res-auto".

Somebody report that my old exercise "Share IntentService among Fragments" not work. So I try to import the downloaded project in a new installed Android ADT, and the following error...sss reported in LogCat:

06-20 23:34:38.358: W/dalvikvm(26472): Unable to resolve superclass of Lcom/example/androidyahooweatherdom/MainActivity; (10)
06-20 23:34:38.358: W/dalvikvm(26472): Link of class 'Lcom/example/androidyahooweatherdom/MainActivity;' failed
06-20 23:34:38.358: W/dalvikvm(26472): threadid=1: thread exiting with uncaught exception (group=0x40cb92d0)
06-20 23:34:38.363: E/AndroidRuntime(26472): FATAL EXCEPTION: main
06-20 23:34:38.363: E/AndroidRuntime(26472): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.androidyahooweatherdom/com.example.androidyahooweatherdom.MainActivity}: java.lang.ClassNotFoundException: com.example.androidyahooweatherdom.MainActivity
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread.access$600(ActivityThread.java:151)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1331)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.os.Handler.dispatchMessage(Handler.java:99)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.os.Looper.loop(Looper.java:155)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread.main(ActivityThread.java:5485)
06-20 23:34:38.363: E/AndroidRuntime(26472): at java.lang.reflect.Method.invokeNative(Native Method)
06-20 23:34:38.363: E/AndroidRuntime(26472): at java.lang.reflect.Method.invoke(Method.java:511)
06-20 23:34:38.363: E/AndroidRuntime(26472): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1028)
06-20 23:34:38.363: E/AndroidRuntime(26472): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:795)
06-20 23:34:38.363: E/AndroidRuntime(26472): at dalvik.system.NativeStart.main(Native Method)
06-20 23:34:38.363: E/AndroidRuntime(26472): Caused by: java.lang.ClassNotFoundException: com.example.androidyahooweatherdom.MainActivity
06-20 23:34:38.363: E/AndroidRuntime(26472): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-20 23:34:38.363: E/AndroidRuntime(26472): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-20 23:34:38.363: E/AndroidRuntime(26472): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.Instrumentation.newActivity(Instrumentation.java:1069)
06-20 23:34:38.363: E/AndroidRuntime(26472): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2258)
06-20 23:34:38.363: E/AndroidRuntime(26472): ... 11 more


Finally, I solve it by correcting Java Build Path - right clicking project -> Java Build Path, select Order and Export tab, check to include both Android 4.2.2 and Android Private Libraries, and click OK.

correct Java Build Path

Actually, I don't know what happen! May be there are something changed in new Android Developer Tools.

No comments:

Post a Comment