2012-12-12 29 views
0

我已將mapview活動添加到應用程序,試圖打開mapView活動會導致崩潰。我對這個問題並不熟悉,其他線程關於它傾向於引用libs,我似乎沒有,或類路徑,這可能是問題,但我真的不明白它。NoClassDefFoundError MapView活動

12-12 18:01:26.075: E/AndroidRuntime(4655): FATAL EXCEPTION: main 
12-12 18:01:26.075: E/AndroidRuntime(4655): java.lang.NoClassDefFoundError: com.b00517566.weekST.MyMapViewer 
12-12 18:01:26.075: E/AndroidRuntime(4655): at com.b00517566.weekST.WeekSevenTwoActivity.updateWeatherView(WeekSevenTwoActivity.java:144) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at com.b00517566.weekST.WeekSevenTwoActivity.access$0(WeekSevenTwoActivity.java:142) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at com.b00517566.weekST.WeekSevenTwoActivity$1.onClick(WeekSevenTwoActivity.java:63) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at android.view.View.performClick(View.java:4202) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at android.view.View$PerformClick.run(View.java:17340) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at android.os.Handler.handleCallback(Handler.java:725) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at android.os.Handler.dispatchMessage(Handler.java:92) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at android.os.Looper.loop(Looper.java:137) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at android.app.ActivityThread.main(ActivityThread.java:5039) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at java.lang.reflect.Method.invokeNative(Native Method) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at java.lang.reflect.Method.invoke(Method.java:511) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 
12-12 18:01:26.075: E/AndroidRuntime(4655): at dalvik.system.NativeStart.main(Native Method) 
public class MyMapViewer extends MapActivity { 
     /** Called when the activity is first created. */ 


     @Override 
     public void onCreate(Bundle savedInstanceState) {//class begins 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.my_mapview);//sets the layout to the xml 

      MapView mapView = (MapView) findViewById(R.id.mapview);//creates a new mapview initialisation 
      mapView.setBuiltInZoomControls(true);//adds the zoom function to the map 

      List<Overlay> mapOverlays = mapView.getOverlays();//the mapOverlay listobject is initialised to teh mapView 
      Drawable drawable = this.getResources().getDrawable(R.drawable.station_icon);//points to marker icon 
      MyItemizedOverlay itemizedoverlay = new MyItemizedOverlay(drawable, this);//instantiates Itemizer 


      GeoPoint point = new GeoPoint((int)(54.684624 * 1e6), 
        (int)(-5.880218 * 1e6));//converts double cords to microdegrees for Geopoint 
      OverlayItem overlayitem = new OverlayItem(point, "Jordanstown", "Shore Road, Newtownabbey, Belfast, Antrim BT370QB "); 


      GeoPoint point1 = new GeoPoint((int)(54.66370520273512 * 1e6), 
        (int)(-5.930986404418945 * 1e6));//converts double cords to microdegrees for Geopoint 
      OverlayItem overlayitem2 = new OverlayItem(point1, "Valley JuiJitsu Club", "Valley Park Newtownabbey BT36 6"); 

      GeoPoint point2 = new GeoPoint((int)(54.644600844283104 * 1e6), 
        (int)(-5.666391849517822 * 1e6));//converts double cords to microdegrees for Geopoint 
      OverlayItem overlayitem3 = new OverlayItem(point2, "Peninsula Martial Arts", "3 Balloo Link, Bangor, Down BT19 7HJ"); 

      itemizedoverlay.addOverlay(overlayitem); //calls teh addOverlay method 
      mapOverlays.add(itemizedoverlay);//adds above to the itemizedoverlay 
     }//end of class 





     @Override 
     protected boolean isRouteDisplayed() { 
      // TODO Auto-generated method stub 
      return false; 
     }//a necessary generated method 
    } 

代碼看起來沒什麼問題,所以這個問題應該進行相關的編輯器或項目屬性中的東西。任何建議如何去解決這個問題將不勝感激。

清單

<?xml version="1.0" encoding="utf-8"?> <manifest 
xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.b00517566.weekST" 
    android:versionCode="1" 
    android:versionName="1.0" > 

    <uses-sdk android:minSdkVersion="9" /> 
    <uses-permission android:name="android.permission.INTERNET"/> 

    <application 
     android:icon="@drawable/ic_launcher" 
     android:label="@string/app_name" > 
     <activity 
      android:name=".WeekSevenTwoActivity" 
      android:label="@string/app_name" > 

     </activity> 
     <activity android:name="splash"> 
       <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity 

      android:name="MyMapViewer" 
      android:theme="@android:style/Theme.NoTitleBar"> 

      </activity> 
    </application> 

</manifest> 
private void updateWeatherView() {  

startActivity(new Intent(this, MyMapViewer.class)); 
}//end of method 

正如你可以看到它很簡單,沒有其他MyMapViewer類

+1

什麼'package'你把'MyMapView'嗎?您是否記得將此活動添加到您的Manifest? – Sam

+0

MyMapView活動與其他軟件包在同一個軟件包中,只有一個軟件包。是的,它在清單中。我也會編輯它。 – TroothHertz

+0

請將代碼發佈到'updateWeatherView()'。你是不是意外地在'WeekSevenTwoActivity'中導入了一些其他的'MyMapViewer'? (這可能會導致一個不同的例外,雖然...) – Sam

回答

2

<uses-library android:name="com.google.android.maps" />

mainfest添加此庫

,並添加權限

<!--permissions --> 
    <uses-permission 
     android:name="android.permission.INTERNET"> 
    </uses-permission> 
    <uses-permission 
     android:name="android.permission.ACCESS_FINE_LOCATION"> 
    </uses-permission> 
+0

我認爲這些爲你工作.. – QuokMoon

+0

嗯,它不會崩潰。非常感謝。 MapView只是顯示網格,我現在做的一箇舊應用也這樣做,這可能與谷歌改變api的事情有關嗎? – TroothHertz

+0

是的..當你在地圖活動上使用googlemap api不是簡單的api .. – QuokMoon