2013-04-28 5 views
6

このバグは永遠に続いています。 (私は "GoogleマップのAndroid API v2のは" 1がオンになっていることを確認しました。)Androidマップ:地図を読み込めませんでした。 Googleサーバーに接続できませんでした

ここMainActivity.javaだ:

package com.example.maptest; 

import android.os.Bundle; 
import android.support.v4.app.FragmentActivity; 
import android.view.Menu; 

public class MainActivity extends FragmentActivity { 

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

    } 
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    }  
} 

マニフェスト:

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

    <permission 
     android:name="com.example.maptest.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature" /> 
    <uses-permission 
     android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> 


    <uses-permission android:name="com.example.maptest.permission.MAPS_RECEIVE" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 


    <uses-feature 
     android:name="android.hardware.location" 
     android:required="true" /> 
    <uses-feature 
     android:name="android.hardware.location.network" 
     android:required="true" /> 
    <uses-feature android:name="android.hardware.location.gps" /> 
    <uses-feature 
     android:name="android.hardware.wifi" 
     android:required="true" /> 

    <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" > 

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

     <activity 
      android:name="com.example.maptest.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> 
     <meta-data 
      android:name="com.google.android.maps.v2.API_KEY" 
      android:value="AIzaSyAoDwhSzOopQ3g8NBe7d0WblR72TkmnVPU" /> 


    </application> 

</manifest> 

activity_main.xml :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:map="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity" > 


    <fragment 
    class="com.google.android.gms.maps.SupportMapFragment" 
    android:id="@+id/map" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:name="com.google.android.gms.maps.MapFragment"/> 

</RelativeLayout> 

助けてください!私は何が間違っていたのか分からない...彼らのどれもが自分のために働いていないので、私は様々なチュートリアルをフォロー/結合することになった。

+0

1.適切にそのAPIキーを登録し、あなたの署名鍵とパッケージ名はありますか? 2.あなたはどれくらいそれをくれましたか? APIキーは必ずしもすぐに有効なわけではありません。 –

答えて

6

1.私が見る最初の問題はここにある:

<fragment 
class="com.google.android.gms.maps.SupportMapFragment" 
android:id="@+id/map" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:name="com.google.android.gms.maps.MapFragment"/> 

この行を削除: クラス= "com.google.android.gms.maps.SupportMapFragment"

をしてandroid:nameを設定

android:name="com.google.android.gms.maps.SupportMapFragment" 

2.トンからこの行を削除しますように

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

これは、GoogleマップAPI V1許可され、API V2で使用すべきではない。彼はファイルをマニフェスト。

は、このブログの記事を見て、すべてを正しく行っていることを確認してください。

Google Maps API V2

3.あなたは通常、記述問題は、使用してAPIキーを生成するか、登録に問題から派生しますAPIコンソール、すべての手順を正しく実行したことが肯定的な場合は、debug.keystoreフォルダを削除し、Eclipseでプロジェクトをコンパイルしてください(新しいSHA1キーになります)。コンソール。私が書いたこのブログの記事を見て、私は右のすべてのステップを行っていることを確認してください。

Google Map API V2 Key

+0

ありがとうsoooo!それはこれまでの最も明白なガイドでした! – Jiexi

+0

あなたは@hotjasmineteaを歓迎します、私はあなたに役立ってうれしいです。 –

+0

こんにちはEmil Adz、私はそれらの手順を実行し、マップサンプルアプリケーションを正常に作成しました。 (Galaxy Ace plus、Galaxy 7inchタブ、sony xperia Zでテストされた)ほとんどのデバイスで動作します。しかし、HTC Desireで同じことをテストしようとすると、「maps.i.k」というクラスが見つかりませんでした。maps.z.ag.aメソッドから参照されました マップを読み込めませんでした。Googleサーバーに接続できませんでした。 。 Google Playサービスがインストールされていることを十字で確認しています。ですから、この問題を解決するために私を助けてください。 – Raj