Android:找不到类定义错误

时间:2011-10-16 21:45:23

标签: button maps android-intent

这是一个带有两个按钮的屏幕,用于显示卫星视图和地图的街景。 streetview和SatelliteView的模块分别完美地工作。但当包含在具有两个按钮(意图)的单个应用程序中时,它会显示以下错误。请帮忙

10-16 16:33:20.400: ERROR/AndroidRuntime(15483): FATAL EXCEPTION: main
10-16 16:33:20.400: ERROR/AndroidRuntime(15483): java.lang.NoClassDefFoundError: com.uhcl.maps.StreetView
10-16 16:33:20.400: ERROR/AndroidRuntime(15483):     at com.uhcl.maps.MymenuActivity.onClick(MymenuActivity.java:39)
10-16 16:33:20.400: ERROR/AndroidRuntime(15483):     at android.view.View$PerformClick.run(View.java:11928)
10-16 16:33:20.400: ERROR/AndroidRuntime(15483):     at android.os.Handler.handleCallback(Handler.java:587)
10-16 16:33:20.400: ERROR/AndroidRuntime(15483):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-16 16:33:20.400: ERROR/AndroidRuntime(15483):     at android.os.Looper.loop(Looper.java:132)
10-16 16:33:20.400: ERROR/AndroidRuntime(15483):     at android.app.ActivityThread.main(ActivityThread.java:4025)
10-16 16:33:20.400: ERROR/AndroidRuntime(15483):     at java.lang.reflect.Method.invokeNative(Native Method)
10-16 16:33:20.400: ERROR/AndroidRuntime(15483):     at java.lang.reflect.Method.invoke(Method.java:491)
10-16 16:33:20.400: ERROR/AndroidRuntime(15483):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
10-16 16:33:20.400: ERROR/AndroidRuntime(15483):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
10-16 16:33:20.400: WARN/ActivityManager(130):   Force finishing activity com.uhcl.maps/.MymenuActivity

这是我的Activity类

package com.uhcl.maps;`
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MymenuActivity extends Activity implements OnClickListener {
/** Called when the activity is first created. */
Button satelliteviwb1, streetviewb2, floormapb3;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.menu);

    satelliteviwb1 = (Button) findViewById(R.id.b1);
    streetviewb2 = (Button) findViewById(R.id.b2);
    floormapb3 = (Button) findViewById(R.id.flooricon);
    satelliteviwb1.setOnClickListener(this);
    streetviewb2.setOnClickListener(this);
    floormapb3.setOnClickListener(this);

}

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

    switch (v.getId()) {


    case R.id.b1:
        Intent intent = new Intent(MymenuActivity.this, SatelliteView.class);
        // Intent intent = new Intent("com.uhcl.maps.SATELLITEVIEW");
        MymenuActivity.this.startActivity(intent);
    case R.id.b2:
        Intent intent2 = new Intent(MymenuActivity.this, StreetView.class);
        // Intent intent2 = new Intent("com.uhcl.maps.STREETVIEW");
        MymenuActivity.this.startActivity(intent2);

    case R.id.flooricon:
        Intent intent3 = new Intent(MymenuActivity.this, FloorView.class);
        // Intent intent2 = new Intent("com.uhcl.maps.STREETVIEW");
        MymenuActivity.this.startActivity(intent3);

    }


    }
}

这是我的地图活动

package com.uhcl.maps;    
import java.util.List;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;
import com.google.android.maps.OverlayItem;

public class SatelliteView extends MapActivity {

public MapView mapView;
public CustomItemizedOverlay itemizedOverlay;
public Drawable drawable;
public List<Overlay> mapOverlays;


public MyLocationOverlay compass;

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    mapView = (MapView) findViewById(R.id.mapview);
    mapView.setBuiltInZoomControls(true);

    mapOverlays = mapView.getOverlays();

     drawable = this.getResources().getDrawable(R.drawable.icon);

 itemizedOverlay = new CustomItemizedOverlay(
            drawable, this);

    //Latitude and Longitude 
    Float sscbla = 29.5843F;
    Float sscblo = -95.098983F;
    Float deltala = 29.577683F;
    Float deltalo = -95.104208F;
    Float csbla = 29.585831F;
    Float csblo = -95.094133F;
    Float arbourla = 29.577933F;
    Float arbourlo = -95.102219F;
    //Float bayoula= F;
    //Float bayoulo= F;

    GeoPoint point = new GeoPoint((int) (deltala * 1E6),
            (int) (deltalo * 1E6));
    OverlayItem overlayitem = new OverlayItem(point, "Hello",
            "I'm at Uhcl, Delta building!");

    GeoPoint point2 = new GeoPoint((int) (sscbla * 1E6),
            (int) (sscblo * 1E6));
    OverlayItem overlayitem2 = new OverlayItem(point2, "Hello",
            "I'm at Uhcl, Student Services building!");

    GeoPoint point3 = new GeoPoint((int) (csbla * 1E6),
            (int) (csblo * 1E6));
    OverlayItem overlayitem3 = new OverlayItem(point3, "Hello",
            "I'm at Uhcl, Central Services building!");

    GeoPoint point4 = new GeoPoint((int) (arbourla * 1E6),
            (int) (arbourlo * 1E6));
    OverlayItem overlayitem4 = new OverlayItem(point4, "Hello",
            "I'm at Uhcl, Arbour building!");


    /*GeoPoint point5 = new GeoPoint((int) (bayoula * 1E6),
            (int) (bayoulo * 1E6));
    OverlayItem overlayitem4 = new OverlayItem(point5, "Hello",
            "I'm at Uhcl, Bayou building!");*/


    itemizedOverlay.addOverlay(overlayitem);
    itemizedOverlay.addOverlay(overlayitem2);
    itemizedOverlay.addOverlay(overlayitem3);
    itemizedOverlay.addOverlay(overlayitem4);
    //itemizedOverlay.addOverlay(overlayitem5);

    mapOverlays.add(itemizedOverlay);

    mapView.setSatellite(true);
    MapController mapController = mapView.getController();

    mapController.animateTo(point2);
    mapController.setZoom(17);

    compass = new MyLocationOverlay(this, mapView);
    mapView.getOverlays().add(compass);

}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    compass.disableCompass();
}

@Override
protected void onResume() {
    // TODO Auto-generated method stub
    super.onResume();
    compass.enableCompass();
}

@Override
protected boolean isRouteDisplayed() {
    return false;
}

}

1 个答案:

答案 0 :(得分:1)

java.lang.NoClassDefFoundError: com.uhcl.maps.StreetView

通常意味着有问题的类不在CLASSPATH中。类加载器找不到它。

这是一个功课问题吗?您是否应该在项目中的某个位置拥有此站点的JAR?

http://prtl.uhcl.edu/portal/page/portal/HOMEPAGE/MAPS_DIRECTIONS/CampusMap