gpt4 book ai didi

java - 导入项目时出现 NoClassDefException

转载 作者:行者123 更新时间:2023-11-29 05:47:13 26 4
gpt4 key购买 nike

我有一个问题,我正在做一个 map 应用程序,我需要使用一些 float 菜单。我找到了一个很好的例子,它发布在这个网站(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'

我认为它与构建路径有关,但这是我第一次将完整项目包含到构建路径中,所以我对此没有任何经验。导入工作正常。

Activity :

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);


}


}

希望能帮到你

最佳答案

清理并构建。

如果这没有帮助,请重新启动 Eclipse 并清理并重新构建。

编辑

你说:

.But when i include this project to buildpath of my project,i get aNoClassDefError.

您的构建路径中似乎包含了一些库项目。您需要将此外部项目标记为库项目。为此,将项目导入工作区后,转到您的主项目。右键单击并转到属性...并选择左侧的“Android”组。在右 Pane 中,您会在最底部找到一个库面板。单击添加并找到另一个项目并将其添加到其中并将其标记为库项目。

enter image description here

完成此操作后,清理构建并执行我之前所说的。 See this Q/A as well .

关于java - 导入项目时出现 NoClassDefException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15411943/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com