2013-07-06 23 views
1

正試圖顯示我的Android手機上的地圖。我檢查了一些代碼,以至於我得到了錯誤。 這是我遇到的錯誤。谷歌地圖V2無法關閉的力量

07-06 15:22:13.359: E/AndroidRuntime(10309): at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source) 

這是我的活動

@Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
    } 

this is my layout 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity" > 

    <fragment xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/map" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      class="com.google.android.gms.maps.SupportMapFragment"/> 
</RelativeLayout> 

這是我的清單文件

<permission 
     android:name="com.android.softroniics.gmaps.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature"/> 

<uses-permission android:name="com.android.softroniics.gmaps.permission.MAPS_RECEIVE"/> 

<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 


<uses-feature 
    android:glEsVersion="0x00020000" 
    android:required="true"/> 


    <meta-data 
     android:name="com.google.android.maps.v2.API_KEY" 
     android:value="AIzaSyApK21PhTXjmLuAQkigWWfXf1E1VS4ECIU"/>   

請找我一個解決方案,以顯示asimple地圖,嘗試了一堆教程顯示AMAP V2的。 在此先感謝」

+0

http://i.stack.imgur.com/ODFFl.png –

+0

告訴我們你的完整清單,XML佈局和活動代碼 – Raghunandan

+0

你有沒有在你的Android地圖項目中引用谷歌播放服務庫項目? – Raghunandan

回答

1

爲了讓地圖來工作,你需要遵循幾個簡單的步驟。我將在這裏總結一下他們:

- 添加谷歌播放服務

這是簡單地將庫項目,並確保庫項目是正確導出的問題。

ADT 22存在一個問題,即它有時會「忘記」將庫導出到您的APK。您可以通過進入您的構建設置並確保已檢查Android Private Libraries來驗證此情況。這將確保您的項目中存儲的任何libs文件夾將被正確導出到APK中。

- 確定您的最低SDK級別。

爲了使用新的谷歌地圖V2 API上,我們需要做兩件事情

  • 在佈局中使用SupportMapFragment代替MapFragment的舊設備
  • 使用FragmentActivity而不是活動的
  • 使用SupportFragmentManager代替FragmentManager在FragmentActivity

- 設置您的地圖鍵正確

使用下面的概述,看看是否一切設置正確:

Overview picture

- 解讀堆棧跟蹤在logcat的

這會告訴你,如果你處理圖書館問題(不包括谷歌播放服務)或地圖API密鑰問題(授權問題)

- 看看本指南+示例項目

我寫了一篇關於如何設置骨架項目的文章。你可以在這裏找到它:http://ddewaele.github.io/GoogleMapsV2WithActionBarSherlock/part1

我也創建了2個使用地圖的骨架項目。您應該能夠克隆它們,更改API密鑰並隨時待命。我有一個較舊的Android版本(使用支持庫)和較新的Android版本(使用原生片段)

https://github.com/ddewaele/GoogleMapsV2WithActionBarSherlock

0
I had made sample code for map . hope this will help [Github Link](https://github.com/shujat89/myAndroidPractices.git)