2012-08-08 56 views
0

我在eclipse中運行一個關於Google Map API的項目時遇到了問題。我有一個新的Google API項目,AVD目標是Google API。但有Android.view.InflateException,平板類錯誤com.google.android.maps.MapView。佈局有什麼問題嗎?在運行Google Map API時出現了InflateException問題

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/jindu" 
     /> 
    <EditText 
     android:id="@+id/et1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="116.46" 
     /> 

</LinearLayout> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    > 
    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/weidu" 
     /> 
    <EditText 
     android:id="@+id/et2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="16.46" 
     /> 
    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/select" 
     /> 
</LinearLayout> 
<com.google.android.maps.MapView 
    android:id="@+id/mapView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:clickable="true" 
    android:enabled="true" 
    android:apiKey="AIzaSyBtMrZJRGm32jIFRxmpgKf3WTqR6AHmkj8" 
    /> 

</LinearLayout> 

我mainfest文件

<uses-sdk 
    android:minSdkVersion="7" 
    android:targetSdkVersion="15" /> 

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

<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
    <activity 
     android:name=".Map" 
     android:label="@string/title_activity_map" > 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

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

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

</application> 

我的課

EditText et1; 
EditText et2; 
Button button1; 
MapView mapView; 
MapController mapController; 

double jindu = 116.46; 
double weidu = 39.92; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.map); 
    et1 = (EditText) this.findViewById(R.id.et1); 
    et2 = (EditText) this.findViewById(R.id.et2); 
    button1 = (Button) this.findViewById(R.id.button1); 
    mapView = (MapView) this.findViewById(R.id.mapView); 
    mapController = mapView.getController();   
    setGeoPoint(); 
    button1.setOnClickListener(new OnClickListener(){ 

     @Override 
     public void onClick(View arg0) { 
      // TODO Auto-generated method stub 
      jindu = Double.parseDouble(et1.getText().toString()); 
      weidu = Double.parseDouble(et2.getText().toString()); 
      setGeoPoint(); 
     } 

    }); 
} 

private void setGeoPoint() { 
    GeoPoint gp = new GeoPoint((int)(jindu*1E6),(int)(weidu*1E6)); 
    mapController.animateTo(gp); 
    mapController.setZoom(18); 
} 

@Override 
public boolean onCreateOptionsMenu(Menu menu) { 
    getMenuInflater().inflate(R.menu.main, menu); 
    return true; 
} 

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

後異常清潔工程之後...和完整的XML文件 – 2012-08-08 09:08:30

+0

具有u currectly給烏爾GoogleMap的API密鑰?如果是的話,可能你還沒有用MapActivity替代活動擴展你的類。 – Aamirkhan 2012-08-08 09:12:46

回答

0

具有u給烏爾GoogleMap的API密鑰currectly?如果是比可能u有沒有擴展UR與MapActivity就地類acitivty。 whenverü使用地圖u需要延長活動

的MapActivity就地進行更詳細的檢查這個問題 android hellomap example giving exception

+0

是的,你知道了,我發現我沒有擴展MapActivity.But然後它出現這個:08-09 03:21:44.391:E/ActivityThread(219):無法找到com.google.settings的提供者信息 08-09 03:21:44.422:E/ActivityThread(219):找不到com.google.settings的提供者信息 08-09 03:21:44.451:E/ActivityThread(219):無法找到提供者信息com.google.settings 08-09 03:21:45.211:I/MapActivity(219):處理網絡更改通知:CONNECTED 08-09 03:21:45.211:E/MapActivity(219):無法獲取連接工廠客戶端 – kingpei 2012-08-09 03:29:51

+0

所以你的錯誤解決? – Aamirkhan 2012-08-09 03:48:08

+0

仍然有問題,地圖不會出現。例外情況如上。 – kingpei 2012-08-09 04:56:27

相關問題