2013-05-24 10 views
7

1)は、灰色の空白の地図を表示します。は+(ズームイン)と - (ズームアウト)ボタンのみです。GoogleマップがAndroidに表示されない

2)私がはdebug.keystoreからキー SHA1抽出 コンソールにキー MAPのAPI V2を生成しました。

3)マニフェストファイルにI を貼り付けました。

4)GOOGLE のMAP API V2は

にオンと私はデバッグのために私のネクサス7を使用します(USBデバッグ)

  • LogCatメッセージ:に失敗しました

ロードマップ。 Googleサーバーに接続できません。これはおそらく認証の問題です(ネットワーク のエラーの可能性があります)。

私はこれらのファイルに間違っていた場合は助けてください。

AndoidManifest.xml

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

    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" /> 
    <permission android:name="metro.tailors.permission.MAPS_RECEIVE" android:protectionLevel="signature"/> 
<uses-permission android:name="metro.tailors.permission.MAPS_RECEIVE"/> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <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"/> 
    <application 
    android:allowBackup="true" 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" 
    android:theme="@style/AppTheme" > 
     <activity 
      android:name="metro.tailors.MainActivity" 
      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="metro.tailors.FactorsActivity" 
     android:label="@string/title_activity_factors" > 
    </activity> 
    <activity 
     android:name="metro.tailors.LadiesCategoryActivity" 
     android:label="@string/title_activity_ladies_category" > 
    </activity> 
    <activity 
     android:name="metro.tailors.GentsCategoryActivity" 
     android:label="@string/title_activity_gents_category" > 
    </activity> 
    <activity 
     android:name="metro.tailors.MapActivity" 
     android:label="@string/title_activity_map" > 
    </activity> 
    <meta-data 
android:name="com.google.android.maps.v2.API_KEY" 
android:value="AIzaSyA2pMJiaPfwlz2yKaRNMZHykQkY_******"/> 

</application> 
</manifest> 

このMapActivityのXMLファイル

 <?xml version="1.0" encoding="utf-8"?> 
<fragment xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/map" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:name="com.google.android.gms.maps.MapFragment"/> 

MapActivity.java

 package metro.tailors; 

     import android.os.Bundle; 
     import android.app.Activity; 

     public class MapActivity extends Activity { 

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

     } 
+2

android:minSdkVersion = "10"この場合、サポートフラグメントを使用する必要があります。もう一度キーを確認してください。 apiコンソールでマップを有効にしているかどうかを確認してください。 – Raghunandan

+0

また、Google Playサービスライブラリ – Raghunandan

答えて

7
あなたが Google Maps for Androidをオンにする必要があります

enter image description here

FragmentサポートはAPI > 11からのみ起動し、だからそれにあなたのmanifestファイルを変更したり、アンドロイド・サポート・ライブラリを追加し、FragmentActivityと側面に沿ってSupportMapFragmentオブジェクトを使用しますか。

サポートライブラリをダウンロードするには、次のリンクをクリックしてください。あなたはAPI 12をターゲットにして上記されている場合にのみ

http://developer.android.com/tools/extras/support-library.html#Downloading

ドキュメント状態使用MapFragmentクラス。それ以外の場合は、SupportMapFragmentを使用します。

https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment

+0

+1を適切に参照していることを確認してください。 – Raghunandan

+0

@Raghunandanを編集してくれてありがとう、私は使用すべきパッケージレベルについてはわからなかった:) –

+0

あなたは大歓迎です。私は見つけて答えにお手伝いできることをうれしく思っています。 – Raghunandan

0

について:

2) I extracted the SHA1 key from the debug.keystore and generated the MAP API V2 key in the console.

だけでなく、あなたのデバッグキーとパッケージ名を指定して、あなたはまた、Google APIコンソールで許可されたアプリのリストにアプリを追加する必要があり、これを実行する必要がありますあなたのプロダクションキーストアのキーとパッケージ名と同様に、

関連する問題