This one really got my nerves. After 2-3 days of going through the various sources, I found a solution to a common problem that arises.
The context is based on the PhoneGap demo provided using Android http://j.mp/MB1pTM. The demo itself, failed for me while doing the exact setup for Android 4.0.3 using PhoneGap API documentation. I get the below error message:
07-16 23:01:58.485: E/AndroidRuntime(778): FATAL EXCEPTION: main
07-16 23:01:58.485: E/AndroidRuntime(778): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.test.shreyas.main/com.test.shreyas.main.HelloCordovaActivity}: java.lang.ClassNotFoundException: com.test.shreyas.main.HelloCordovaActivity
07-16 23:01:58.485: E/AndroidRuntime(778): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
07-16 23:01:58.485: E/AndroidRuntime(778): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
07-16 23:01:58.485: E/AndroidRuntime(778): at android.app.ActivityThread.access$600(ActivityThread.java:123)
07-16 23:01:58.485: E/AndroidRuntime(778): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
07-16 23:01:58.485: E/AndroidRuntime(778): at android.os.Handler.dispatchMessage(Handler.java:99)
07-16 23:01:58.485: E/AndroidRuntime(778): at android.os.Looper.loop(Looper.java:137)
07-16 23:01:58.485: E/AndroidRuntime(778): at android.app.ActivityThread.main(ActivityThread.java:4424)
07-16 23:01:58.485: E/AndroidRuntime(778): at java.lang.reflect.Method.invokeNative(Native Method)
07-16 23:01:58.485: E/AndroidRuntime(778): at java.lang.reflect.Method.invoke(Method.java:511)
07-16 23:01:58.485: E/AndroidRuntime(778): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
07-16 23:01:58.485: E/AndroidRuntime(778): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
07-16 23:01:58.485: E/AndroidRuntime(778): at dalvik.system.NativeStart.main(Native Method)
07-16 23:01:58.485: E/AndroidRuntime(778): Caused by: java.lang.ClassNotFoundException: com.test.shreyas.main.HelloCordovaActivity
07-16 23:01:58.485: E/AndroidRuntime(778): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-16 23:01:58.485: E/AndroidRuntime(778): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-16 23:01:58.485: E/AndroidRuntime(778): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-16 23:01:58.485: E/AndroidRuntime(778): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
07-16 23:01:58.485: E/AndroidRuntime(778): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
07-16 23:01:58.485: E/AndroidRuntime(778): ... 11 more
The stupid mistake to avoid is to NOT link external libraries in your build path.
I configured
cordova-1.9.0.jarto be linked from the stored location and the app used to crash everytime.So the tip is,
Always import the referenced libraries onto a separate folder into your Eclipse project, say /libs and then link it in your build path to avoid such mess and time waste.
Cheers!