Rip's Domain

Android: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo

Posted in Uncategorized by rip747 on April 5, 2013

When trying to launch our android application onto the emulator through eclipse, i get the following error:

04-05 15:12:24.082: E/AndroidRuntime(386): FATAL EXCEPTION: main

04-05 15:12:24.082: E/AndroidRuntime(386): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.sheriff/org.sheriff.BizTownActivity}: java.lang.ClassNotFoundException: org.sheriff.BizTownActivity in loader dalvik.system.PathClassLoader[/data/app/org.sheriff-2.apk]

04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1739)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1831)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.access$500(ActivityThread.java:122)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1024)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.os.Looper.loop(Looper.java:132)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.main(ActivityThread.java:4123)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.reflect.Method.invoke(Method.java:491)
04-05 15:12:24.082: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
04-05 15:12:24.082: E/AndroidRuntime(386): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
04-05 15:12:24.082: E/AndroidRuntime(386): at dalvik.system.NativeStart.main(Native Method)
04-05 15:12:24.082: E/AndroidRuntime(386): Caused by: java.lang.ClassNotFoundException: org.sheriff.BizTownActivity in loader dalvik.system.PathClassLoader[/data/app/org.sheriff-2.apk]
04-05 15:12:24.082: E/AndroidRuntime(386): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:251)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.ClassLoader.loadClass(ClassLoader.java:540)
04-05 15:12:24.082: E/AndroidRuntime(386): at java.lang.ClassLoader.loadClass(ClassLoader.java:500)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.Instrumentation.newActivity(Instrumentation.java:1022)
04-05 15:12:24.082: E/AndroidRuntime(386): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1730)
04-05 15:12:24.082: E/AndroidRuntime(386): … 11 more

 

After searching through StackOverflow and Google. I couldn’t come up with an answer. For some reason I had a look at my .classpath file and noticed something:

<?xml version=”1.0″ encoding=”UTF-8″?>
<classpath>
<classpathentry kind=”src” path=”gen”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.ANDROID_FRAMEWORK”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.LIBRARIES”/>
<classpathentry kind=”output” path=”bin/classes”/>
</classpath>

If you look closely you’ll notice that there isn’t a classpathentry for src directory itself where org.sheriff.BizTownActivity is located. I changed the .classpath to reflect the src path:

<?xml version=”1.0″ encoding=”UTF-8″?>
<classpath>
<classpathentry kind=”src” path=”src”/>
<classpathentry kind=”src” path=”gen”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.ANDROID_FRAMEWORK”/>
<classpathentry kind=”con” path=”com.android.ide.eclipse.adt.LIBRARIES”/>
<classpathentry kind=”output” path=”bin/classes”/>
</classpath>

and it worked!!!

Tagged with:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: