0

I am trying to figureout what is wrong with following code that is causing "class not found" exception but I am not able to solved it.

I am starting an activity that is extending MapActivity from mapquest-android-sdk-1.0.5.jar map quest library.

    public void onRoutePlanButtonClick(View v) {
        start = ((EditText) findViewById(R.id.start)).getText().toString();
        destination = ((EditText) findViewById(R.id.destination)).getText()
                .toString();

        Driver driver = new Driver();
        driver.setStart(start);
        driver.setDestination(destination);
        Intent intent = new Intent(this, DriverMap.class);
        startActivity(intent);
    }

the class DriverMap exists in com.thumbup.driver but the following code is causing the error

Intent intent = new Intent(this, DriverMap.class);

NOTES:

  1. I made sure the map quest lib is on the correct path
  2. When I call another Activity then it works without any problem
  3. DriverMap extends ThumbUpMap implements ThumbUpLocationProvider
  4. The activity that is calling DriverMap is storing some data locally, using SharedPreferences
  5. I am using Android 2.3.3

Error from LogCat (adroid SDK):

06-03 14:29:24.558: E/dalvikvm(1979): Could not find class 'com.thumbup.driver.DriverMap', referenced from method com.thumbup.driver.Journey.onRoutePlanButtonClick
06-03 14:29:24.558: W/dalvikvm(1979): VFY: unable to resolve const-class 58 (Lcom/thumbup/driver/DriverMap;) in Lcom/thumbup/driver/Journey;
06-03 14:29:24.558: D/dalvikvm(1979): VFY: replacing opcode 0x1c at 0x0037
06-03 14:29:24.558: D/dalvikvm(1979): VFY: dead code 0x0039-003f in Lcom/thumbup/driver/Journey;.onRoutePlanButtonClick (Landroid/view/View;)V
06-03 14:29:38.238: D/AndroidRuntime(1979): Shutting down VM
06-03 14:29:38.238: W/dalvikvm(1979): threadid=1: thread exiting with uncaught exception (group=0x40015578)
06-03 14:29:38.246: E/AndroidRuntime(1979): FATAL EXCEPTION: main
06-03 14:29:38.246: E/AndroidRuntime(1979): java.lang.IllegalStateException: Could not execute method of the activity
06-03 14:29:38.246: E/AndroidRuntime(1979):     at android.view.View$1.onClick(View.java:2154)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at android.view.View.performClick(View.java:2538)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at android.view.View$PerformClick.run(View.java:9152)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at android.os.Handler.handleCallback(Handler.java:587)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at android.os.Handler.dispatchMessage(Handler.java:92)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at android.os.Looper.loop(Looper.java:123)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at android.app.ActivityThread.main(ActivityThread.java:3687)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at java.lang.reflect.Method.invokeNative(Native Method)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at java.lang.reflect.Method.invoke(Method.java:507)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at dalvik.system.NativeStart.main(Native Method)
06-03 14:29:38.246: E/AndroidRuntime(1979): Caused by: java.lang.reflect.InvocationTargetException
06-03 14:29:38.246: E/AndroidRuntime(1979):     at java.lang.reflect.Method.invokeNative(Native Method)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at java.lang.reflect.Method.invoke(Method.java:507)
06-03 14:29:38.246: E/AndroidRuntime(1979):     at android.view.View$1.onClick(View.java:2149)
06-03 14:29:38.246: E/AndroidRuntime(1979):     ... 11 more
06-03 14:29:38.246: E/AndroidRuntime(1979): Caused by: java.lang.NoClassDefFoundError: com.thumbup.driver.DriverMap
06-03 14:29:38.246: E/AndroidRuntime(1979):     at com.thumbup.driver.Journey.onRoutePlanButtonClick(Journey.java:32)
06-03 14:29:38.246: E/AndroidRuntime(1979):     ... 14 more

When I swtiched to Android 2.3.3, it is working! but not with 4.2.2

amjad
  • 2,876
  • 7
  • 26
  • 43

1 Answers1

0

Class not found suggests that your project cannot find the classes, probably because the .jar-file isn't included. Since you can call other activities I suppose that you haven't added the jar file properly.

Are you sure that the library is included in the build path? Or, if you're not supposed to include it as a library, are you running an Android target instead of a Google target?

Try to fins the answer to one of the two above questions and the project will work!

Pphoenix
  • 1,423
  • 1
  • 15
  • 37