我有一个问题,我正在做一个地图应用程序,我需要使用一些浮动菜单。我发现了一个很好的例子,它被发布在这个网站(QuickAction)中。但是当我将这个项目包含到我的项目的构建路径中时,我得到一个 NoClassDefError。这是我的日志。
日志猫:
03-14 15:19:17.858: W/dalvikvm(1807): VFY: unable to find class referenced in signature (Lnet/londatiga/android/QuickAction;)
03-14 15:19:17.888: E/dalvikvm(1807): Could not find class 'net.londatiga.android.ActionItem', referenced from method com.gps.gpsclient.GPSClientActivity.createFloatingMenu
03-14 15:19:17.888: W/dalvikvm(1807): VFY: unable to resolve new-instance 646 (Lnet/londatiga/android/ActionItem;) in Lcom/gps/gpsclient/GPSClientActivity;
03-14 15:19:17.888: D/dalvikvm(1807): VFY: replacing opcode 0x22 at 0x0000
03-14 15:19:17.898: D/dalvikvm(1807): DexOpt: unable to opt direct call 0x0f95 at 0x02 in Lcom/gps/gpsclient/GPSClientActivity;.createFloatingMenu
03-14 15:19:17.908: D/dalvikvm(1807): DexOpt: unable to opt direct call 0x0f98 at 0x20 in Lcom/gps/gpsclient/GPSClientActivity;.createFloatingMenu
03-14 15:19:17.968: I/org.osmdroid.views.MapView(1807): Using tile source: org.osmdroid.tileprovider.tilesource.XYTileSource@410e7460
03-14 15:19:17.978: I/org.osmdroid.tileprovider.modules.MapTileFileStorageProviderBase(1807): sdcard state: mounted
03-14 15:19:17.978: I/org.osmdroid.tileprovider.modules.MapTileFileStorageProviderBase(1807): sdcard state: mounted
03-14 15:19:18.038: I/org.osmdroid.tileprovider.MapTileProviderBase(1807): rescale tile cache from 0 to 10
03-14 15:19:18.088: I/org.osmdroid.tileprovider.MapTileProviderBase(1807): Finished rescale in 44ms
03-14 15:19:18.098: D/dalvikvm(1807): GC_CONCURRENT freed 141K, 3% free 6877K/7047K, paused 2ms+7ms
03-14 15:19:18.128: D/dalvikvm(1807): GC_FOR_ALLOC freed 39K, 4% free 7144K/7431K, paused 28ms
03-14 15:19:18.258: D/dalvikvm(1807): GC_CONCURRENT freed 206K, 3% free 7467K/7687K, paused 2ms+3ms
03-14 15:19:18.258: D/AndroidRuntime(1807): Shutting down VM
03-14 15:19:18.268: I/dalvikvm(1807): threadid=3: reacting to signal 3
03-14 15:19:18.288: W/dalvikvm(1807): threadid=1: thread exiting with uncaught exception (group=0x40a671f8)
03-14 15:19:18.298: I/dalvikvm(1807): Wrote stack traces to '/data/anr/traces.txt'
03-14 15:19:18.298: E/AndroidRuntime(1807): FATAL EXCEPTION: main
03-14 15:19:18.298: E/AndroidRuntime(1807): java.lang.NoClassDefFoundError: net.londatiga.android.ActionItem
03-14 15:19:18.298: E/AndroidRuntime(1807): at com.gps.gpsclient.GPSClientActivity.createFloatingMenu(GPSClientActivity.java:61)
03-14 15:19:18.298: E/AndroidRuntime(1807): at com.gps.gpsclient.GPSClientActivity.onCreate(GPSClientActivity.java:47)
03-14 15:19:18.298: E/AndroidRuntime(1807): at android.app.Activity.performCreate(Activity.java:4492)
03-14 15:19:18.298: E/AndroidRuntime(1807): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-14 15:19:18.298: E/AndroidRuntime(1807): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-14 15:19:18.298: E/AndroidRuntime(1807): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-14 15:19:18.298: E/AndroidRuntime(1807): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-14 15:19:18.298: E/AndroidRuntime(1807): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-14 15:19:18.298: E/AndroidRuntime(1807): at android.os.Handler.dispatchMessage(Handler.java:99)
03-14 15:19:18.298: E/AndroidRuntime(1807): at android.os.Looper.loop(Looper.java:137)
03-14 15:19:18.298: E/AndroidRuntime(1807): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-14 15:19:18.298: E/AndroidRuntime(1807): at java.lang.reflect.Method.invokeNative(Native Method)
03-14 15:19:18.298: E/AndroidRuntime(1807): at java.lang.reflect.Method.invoke(Method.java:511)
03-14 15:19:18.298: E/AndroidRuntime(1807): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-14 15:19:18.298: E/AndroidRuntime(1807): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-14 15:19:18.298: E/AndroidRuntime(1807): at dalvik.system.NativeStart.main(Native Method)
03-14 15:19:18.558: D/dalvikvm(1807): GC_CONCURRENT freed 406K, 7% free 7450K/7943K, paused 3ms+2ms
03-14 15:19:18.768: I/dalvikvm(1807): threadid=3: reacting to signal 3
03-14 15:19:18.768: I/dalvikvm(1807): Wrote stack traces to '/data/anr/traces.txt'
03-14 15:19:18.888: I/dalvikvm(1807): threadid=3: reacting to signal 3
03-14 15:19:18.898: I/dalvikvm(1807): Wrote stack traces to '/data/anr/traces.txt'
我认为它对那个构建路径有些想法,但这是我第一次将完整项目包含到构建路径中,所以我对此没有任何经验。导入工作正常。
活动:
package com.gps.gpsclient;
import net.londatiga.android.ActionItem;
import net.londatiga.android.QuickAction;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import org.osmdroid.views.MapView;
import com.gps.gpsclient.R;
public class GPSClientActivity extends Activity {
private MapView view;
private MapDrawer mainDrawer;
private QuickAction mQuickAction;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gps);
view = (MapView) findViewById(R.id.mapView);
view.setTileSource(TileSourceFactory.MAPNIK);
view.setBuiltInZoomControls(true);
MapController mapController = view.getController();
mapController.setZoom(10);
GeoPoint point2 = new GeoPoint(51496994, -134733);
mapController.setCenter(point2);
mainDrawer=new MapDrawer(view);
createFloatingMenu();
final Button button = (Button) findViewById(R.id.addButton);
button.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
mQuickAction.show(view);
return false;
}
});
}
public void createFloatingMenu()
{
ActionItem item=new ActionItem();
item.setIcon(getResources().getDrawable(R.drawable.ic_launcher));
item.setTitle("Custom");
mQuickAction =new QuickAction(view.getContext());
mQuickAction.addActionItem(item);
}
}
希望你能帮忙