我试图找出导致“找不到类”异常的代码有什么问题,但我无法解决它。
我正在开始一项从mapquest-android-sdk-1.0.5.jar地图任务库扩展MapActivity的活动。
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);
}
类DriverMap存在于com.thumbup.driver中,但以下代码导致错误
Intent intent = new Intent(this, DriverMap.class);
注意:
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
当我开始使用Android 2.3.3时,它正在运行!但不是4.2.2
答案 0 :(得分:0)
未找到类表明您的项目无法找到类,可能是因为未包含.jar文件。由于您可以调用其他活动,我认为您没有正确添加jar文件。
您确定该库是否包含在构建路径中? 或者,如果您不打算将其作为库添加,那么您是在运行Android目标而不是Google目标吗?
尝试解决上述两个问题之一的答案,该项目将有效!