我在我的android项目的同一个java文件中声明了一个类,我的代码由于某种原因不能识别它吗?当我在模拟器中运行它时,我在运行时得到一个NoClassDefFoundError。
当我尝试在模拟器中运行我的Android应用程序时,我收到以下错误:
01-16 19:58:41.394: E/dalvikvm(2648): Could not find class 'nl.sogeti.android.gpstracker.viewer.map.overlay.AsyncOverlay$SegmentOsmOverlay', referenced from method nl.sogeti.android.gpstracker.viewer.map.overlay.AsyncOverlay.<init>
01-16 19:58:41.394: W/dalvikvm(2648): VFY: unable to resolve new-instance 939 (Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay$SegmentOsmOverlay;) in Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay;
01-16 19:58:41.394: D/dalvikvm(2648): VFY: replacing opcode 0x22 at 0x0044
01-16 19:58:41.394: W/dalvikvm(2648): Unable to resolve superclass of Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay$SegmentMapQuestOverlay; (562)
01-16 19:58:41.394: W/dalvikvm(2648): Link of class 'Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay$SegmentMapQuestOverlay;' failed
01-16 19:58:41.404: W/dalvikvm(2648): VFY: unable to find class referenced in signature (Lcom/mapquest/android/maps/Overlay;)
01-16 19:58:41.404: W/dalvikvm(2648): Unable to resolve superclass of Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay$SegmentOsmOverlay; (1422)
01-16 19:58:41.404: W/dalvikvm(2648): Link of class 'Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay$SegmentOsmOverlay;' failed
01-16 19:58:41.414: W/dalvikvm(2648): VFY: unable to find class referenced in signature (Lorg/osmdroid/views/overlay/Overlay;)
01-16 19:58:41.414: W/dalvikvm(2648): Unable to resolve superclass of Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay$SegmentOsmOverlay; (1422)
01-16 19:58:41.414: W/dalvikvm(2648): Link of class 'Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay$SegmentOsmOverlay;' failed
01-16 19:58:41.427: D/dalvikvm(2648): DexOpt: unable to opt direct call 0x16f6 at 0x4e in Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay;.<init>
01-16 19:58:41.434: W/dalvikvm(2648): Unable to resolve superclass of Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay$SegmentMapQuestOverlay; (562)
01-16 19:58:41.434: W/dalvikvm(2648): Link of class 'Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay$SegmentMapQuestOverlay;' failed
01-16 19:58:41.434: D/dalvikvm(2648): DexOpt: unable to opt direct call 0x16f2 at 0x55 in Lnl/sogeti/android/gpstracker/viewer/map/overlay/AsyncOverlay;.<init>
01-16 19:58:41.468: D/AndroidRuntime(2648): Shutting down VM
01-16 19:58:41.474: W/dalvikvm(2648): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
01-16 19:58:41.514: E/AndroidRuntime(2648): FATAL EXCEPTION: main
01-16 19:58:41.514: E/AndroidRuntime(2648): java.lang.NoClassDefFoundError: nl.sogeti.android.gpstracker.viewer.map.overlay.AsyncOverlay$SegmentOsmOverlay
01-16 19:58:41.514: E/AndroidRuntime(2648): at nl.sogeti.android.gpstracker.viewer.map.overlay.AsyncOverlay.<init>(AsyncOverlay.java:92)
01-16 19:58:41.514: E/AndroidRuntime(2648): at nl.sogeti.android.gpstracker.viewer.map.overlay.BitmapSegmentsOverlay.<init>(BitmapSegmentsOverlay.java:23)
01-16 19:58:41.514: E/AndroidRuntime(2648): at nl.sogeti.android.gpstracker.viewer.map.LoggerMapHelper.onCreate(LoggerMapHelper.java:195)
01-16 19:58:41.514: E/AndroidRuntime(2648): at nl.sogeti.android.gpstracker.viewer.map.GoogleLoggerMap.onCreate(GoogleLoggerMap.java:90)
01-16 19:58:41.514: E/AndroidRuntime(2648): at android.app.Activity.performCreate(Activity.java:5104)
01-16 19:58:41.514: E/AndroidRuntime(2648): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
01-16 19:58:41.514: E/AndroidRuntime(2648): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
01-16 19:58:41.514: E/AndroidRuntime(2648): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
01-16 19:58:41.514: E/AndroidRuntime(2648): at android.app.ActivityThread.access$600(ActivityThread.java:141)
01-16 19:58:41.514: E/AndroidRuntime(2648): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
01-16 19:58:41.514: E/AndroidRuntime(2648): at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 19:58:41.514: E/AndroidRuntime(2648): at android.os.Looper.loop(Looper.java:137)
01-16 19:58:41.514: E/AndroidRuntime(2648): at android.app.ActivityThread.main(ActivityThread.java:5039)
01-16 19:58:41.514: E/AndroidRuntime(2648): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 19:58:41.514: E/AndroidRuntime(2648): at java.lang.reflect.Method.invoke(Method.java:511)
01-16 19:58:41.514: E/AndroidRuntime(2648): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-16 19:58:41.514: E/AndroidRuntime(2648): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-16 19:58:41.514: E/AndroidRuntime(2648): at dalvik.system.NativeStart.main(Native Method)
01-16 19:59:01.474: W/Trace(2666): Unexpected value from nativeGetEnabledTags: 0
这是我的代码:
AsyncOverlay(LoggerMap loggermap, Handler handler)
{
mLoggerMap = loggermap;
mHandler = handler;
mWidth = 1;
mHeight = 1;
mPaint = new Paint();
mActiveZoomLevel = -1;
mActiveBitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888);
mActiveTopLeft = new GeoPoint(0, 0);
mActivePointTopLeft = new Point();
mCalculationBitmap = Bitmap.createBitmap(mWidth, mHeight, Bitmap.Config.ARGB_8888);
mOsmOverlay = new SegmentOsmOverlay(mLoggerMap.getActivity(), mLoggerMap, this);
mMapQuestOverlay = new SegmentMapQuestOverlay(this);
}
这是我的班级:
static class SegmentOsmOverlay extends org.osmdroid.views.overlay.Overlay {
AsyncOverlay mSegmentOverlay;
LoggerMap mLoggerMap;
public SegmentOsmOverlay(Context ctx, LoggerMap map, AsyncOverlay segmentOverlay)
{
super(ctx);
mLoggerMap = map;
mSegmentOverlay = segmentOverlay;
}
public AsyncOverlay getSegmentOverlay()
{
return mSegmentOverlay;
}
@Override
public boolean onSingleTapUp(MotionEvent e, org.osmdroid.views.MapView openStreetMapView)
{
int x = (int) e.getX();
int y = (int) e.getY();
GeoPoint tappedGeoPoint = mLoggerMap.fromPixels(x, y);
return mSegmentOverlay.commonOnTap(tappedGeoPoint);
}
@Override
protected void draw(Canvas canvas, org.osmdroid.views.MapView view, boolean shadow)
{
if (!shadow)
{
mSegmentOverlay.draw(canvas);
}
}
}
有什么建议吗?
答案 0 :(得分:0)
尝试清理你的项目(项目 - &gt;干净......) 然后刷新项目(右键单击项目名称 - > gt;刷新..)
请告诉我它是否有效。