2014-01-16 64 views
0

我使用谷歌地圖上exlipse AVD。(我使用的是Nexus One和S)Android虛擬設備谷歌地圖V2黑色屏幕放大

它保存在一個灰色的後得到黑屏。

我已經搜索並嘗試了幾個小時,但沒有運氣。

LogCat中存在錯誤:Google Maps Android API v2僅支持使用OpenGL ES 2.0及更高版本的設備。

的API密鑰與生成的命令:keytool -list -v -keystore debug.keystore

下面是manifest.xml中

 <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
     package="com.example.test" 
     android:versionCode="1" 
     android:versionName="1.0" > 
     <permission 
      android:name="com.example.test.permission.MAPS_RECEIVE" 
      android:protectionLevel="signature"/> 
     <uses-permission android:name="com.example.test.permission.MAPS_RECEIVE"/> 
     <uses-sdk 
      android:minSdkVersion="12" 
      android:targetSdkVersion="19" /> 
     <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 
     <uses-permission android:name="android.permission.INTERNET" /> 
     <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" /> 
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 

     <!-- Required to show current location --> 
     <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
     <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 

     <!-- Required OpenGL ES 2.0. for Maps V2 --> 
     <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="com.example.test.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> 
      <uses-library android:name="com.google.android.maps"/> 
      <meta-data 
       android:name="com.google.android.maps.v2.API_KEY" 
       android:value="AIz...f3A" /> 
      <meta-data 
       android:name="com.google.android.gms.version" 
       android:value="@integer/google_play_services_version" /> 
     </application> 
    </manifest> 

這裏的main.xml中

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

最後MainActivity.java

package com.example.test; 
    import com.google.android.gms.maps.GoogleMap; 
    import com.google.android.gms.maps.MapFragment; 
    import android.os.Bundle; 
    import android.widget.Toast; 
    import android.app.Activity; 

    public class MainActivity extends Activity { 
     private GoogleMap googleMap; 
     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.main); 
      try{ 
      initilizeMap(); 
      }catch(Exception e){ 
      e.printStackTrace(); 
      } 
     } 
     private void initilizeMap(){ 
      if(googleMap==null){ 
      googleMap=((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap(); 
      if(googleMap==null){ 
       Toast.makeText(getApplicationContext(),"Sorry! unable to create maps", Toast.LENGTH_SHORT).show(); 
      } 
      } 
     } 
     @Override 
     protected void onResume() { 
      super.onResume(); 
      initilizeMap(); 
     } 
    } 

真的很感謝您的幫助!

+0

在真實設備上進行測試。虛擬設備是否安裝了谷歌播放服務apk? – Raghunandan

+0

你的AVD版本有哪些版本?請注意,只有Android 4.2.2及更高版本的Google API平臺包含Google Play服務。 – fasteque

+0

我開始使用谷歌apis的虛擬設備不是android 4.4,但沒有安裝任何apks ... // @ Raghunandan – SilverMoon

回答

0

您需要任何的下方,以測試谷歌播放服務的apk:

Android模擬器與AVD運行基於Android的4.2.2或更高版本的谷歌API的 平臺。

+0

我通過GooglePlayServicesUtil.isGooglePlayServicesAvailable檢查了谷歌播放服務的狀態,它在AVD上正常工作... – SilverMoon