2010-10-19 106 views
0

我的地图活动在启动时崩溃。我已经包含了所有的权限,并且在一个新的独立的地图项目上进行了测试,它与底层代码很好地协作。地图活动在调用时崩溃!

相反,当我在应用程序中合并相同的代码时,只要调用此活动就会崩溃。我的一个项目提交明天早上有,所以请尽快回复

我的地图活动如下

  package com.healthcare.iFind; 

      import com.google.android.maps.MapActivity; 
      import com.google.android.maps.MapView; 
      import com.google.android.maps.MapView.LayoutParams; 

      import android.os.Bundle; 
      import android.view.View; 
      import android.widget.LinearLayout; 

      public class MapsActivity extends MapActivity 
      { 
      MapView mapView; 

      /** Called when the activity is first created. */ 
      @Override 
      public void onCreate(Bundle savedInstanceState) 
      { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.maps); 


      mapView = (MapView) findViewById(R.id.mapView); 
      LinearLayout zoomLayout = (LinearLayout)findViewById(R.id.zoom); 
      View zoomView = mapView.getZoomControls(); 

      zoomLayout.addView(zoomView, 
      new LinearLayout.LayoutParams(
      LayoutParams.WRAP_CONTENT, 
      LayoutParams.WRAP_CONTENT)); 
      mapView.displayZoomControls(true); 

      } 

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

我的AndroidManifest.xml文件:

  <?xml version="1.0" encoding="utf-8"?> 
      <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
      package="com.healthcare.iFind" 
      android:versionCode="1" 
      android:versionName="1.0.0"> 
      <application android:icon="@drawable/icon" android:label="@string/app_name"> 
      <uses-library android:name="com.google.android.maps" /> 
      <activity android:name=".HomeScreen" 
      android:label="@string/app_name"> 
      <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
      </activity> 
      <activity android:name="MessageList"></activity> 
      <activity android:name="RateDoctor"></activity> 
      <activity android:name="RateQuiz"></activity> 
      <activity android:name="DetailedDoctor"></activity> 
      <activity android:name="DoctorProfile"></activity> 
      <activity android:name=".MapsActivity"/> 
      </application> 

我maplayout.xml文件。

  </manifest> 

      <?xml version="1.0" encoding="utf-8"?> 
      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

      <com.google.android.maps.MapView 
      android:id="@+id/mapView" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:enabled="true" 
      android:clickable="true" 
      android:apiKey="mykey" 
      /> 
      <LinearLayout android:id="@+id/zoom" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_centerHorizontal="true" 
      /> 

      </RelativeLayout> 
+1

请不要说你的问题很紧急;它不会加速事情。如何提出问题智能方法 - http://www.catb.org/esr/faqs/smart-questions.html#urgent - 建议阅读任何人在这些社区网站上寻求帮助。 – junkdog 2010-10-19 06:58:50

+3

这就是说,你的logcat说什么?它应该说错误发生在哪里 - 如果您使用的是Eclipse,请转到DDMS视角。 – junkdog 2010-10-19 07:01:35

+0

它说,无法解析超级类的Lcom/healthcare/iFind/MapsActivity;它基本上显示了一个NoClassDefFoundError。但是我包含了Google API + Android 2.2包,并且在我的Eclipse代码中也没有出现错误。我能做什么错了?对于这种紧急情况,我很抱歉,我一直在研究这个问题,而且我没有让我的应用看起来很笨,我不会再这样做。 – standroid 2010-10-19 13:23:28

回答

0

alt text

旁边的红线,没有您的工作空间像她那样。只是为了确保你正在编译API而不是常规的2.2包。

此代码在我的模拟器上运行得很好。 (2.2使用谷歌API)

以防万一,变化:

<activity android:name=".MapsActivity"/> 

<activity android:name=".MapsActivity"/></activity> 

它不应该做多大的性差异,但只是为了让您清单的一致性。

+0

我拥有与您所说的一切完全一样的东西,看起来像我的模拟器出了问题。但不是这个错误支持怪异?:Lcom/healthcare/iFind/MapsActivity – standroid 2010-10-19 16:15:31

+0

从logcat发布更多信息,它不会至少给出一个崩溃的行。将整个logCat错误复制到原始问题中。 您可以尝试删除该AVD并创建一个新的AVD。 – blindstuff 2010-10-19 16:18:41

+0

我创建了一个新的AVD,但问题仍然存在。这是Logcat中的错误:http://fpaste.org/B3fX/ – standroid 2010-10-19 17:33:20