2013-07-12 39 views
3

我使用v2版本實現了Google Map。我測試了真實設備上的應用它工作正常,但我想在仿真器上測試它。我怎樣才能做到這一點 ?我們如何在仿真器上測試Google Map API v2

這裏是我的manifest.xml

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

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

<permission 
     android:name="com.example.demogooglemapv2.permission.MAPS_RECEIVE" 
     android:protectionLevel="signature"/> 

<uses-permission android:name="com.example.demogooglemapv2.permission.MAPS_RECEIVE"/> 


    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 

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

    <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.demogooglemapv2.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="AIzaSyB2jvxyj-WbkYc1Y1WR9Sc1E1W22QywA_k" 
      /> 
    </application> 

</manifest> 

這裏是我的activity_main.xml中

<LinearLayout 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" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 



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



</LinearLayout> 

這裏是我的mainActivity.java

package com.example.demogooglemapv2; 

import com.google.android.gms.common.ConnectionResult; 
import com.google.android.gms.common.GooglePlayServicesUtil; 

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

import android.support.v4.app.FragmentActivity; 
import android.util.Log; 
import android.view.Menu; 
import android.widget.Toast; 

public class MainActivity extends FragmentActivity{ 

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

     int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); 

      if (resultCode == ConnectionResult.SUCCESS){ 
      Toast.makeText(getApplicationContext(), 
      "isGooglePlayServicesAvailable SUCCESS", 
      Toast.LENGTH_LONG).show(); 
      }else{ 

      } 




    } 

    @Override 
    protected void onResume() { 
     // TODO Auto-generated method stub 
     super.onResume(); 

     int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()); 

      if (resultCode == ConnectionResult.SUCCESS){ 
      Toast.makeText(getApplicationContext(), 
      "isGooglePlayServicesAvailable SUCCESS", 
      Toast.LENGTH_LONG).show(); 

      Log.v(">>>>>>>>>>>>>.", "successs"); 
      }else{ 

      } 
    } 

    @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; 
    } 

} 
+0

我會建議你測試它在真實設備上。 – Raghunandan

+0

@Raghunandan我在真實設備上測試它工作正常,但我想測試它的模擬器也 –

+0

你可以檢查這個解決方法http://blog-emildesign.rhcloud.com/?p=527。但是如果您已經在設備上測試過,爲什麼要在模擬器上測試它?用戶在真實設備上的應用程序不在仿真器上。所以,如果它在設備上工作,我不會太擔心模擬器 – Raghunandan

回答

3

我也在這個問題很長時間stucked。我沒有一個Android設備使用,所以我必須在模擬器上嘗試。

我發現讓地圖在模擬器上工作的最佳方式是使用另一個模擬器代替eclipse模擬器。

搜索Genymotion。是我試過的最好的模擬器。您可以使用谷歌播放下載任何應用程序,並且地圖在此上正常工作。

對不起,我的英語不好。

+0

您的英語其實並不是那麼糟糕大聲笑 – uofc

+0

謝謝,Genymotion工作完美 –

0

你就不能。模擬器目前不支持地圖V2。

+0

,但我看了一些視頻教程,顯示在emulater地圖 –

+0

它是V1? –

+0

不,它是第2版。只是看到這個視頻http://www.youtube.com/watch?v=awX5T-EwLPc –

3

Google map api 2不支持在android中運行。它Refer this,但它是可能的,你可以安裝一些apk到模擬器來訪問谷歌地圖API模擬器V2的see here

+0

我遵循這個鏈接..但我沒有得到任何解決方案..當我嘗試推vending.apk。一個錯誤發生「設備上沒有更多空間」現在我怎麼解決這個問題 –

+0

它是由於模擬器中可用的存儲空間較少。卸載安裝在仿真器中的無用應用程序,並通過在AVD管理器中編輯仿真器來增加內部存儲空間。 – Nas

+0

我更改內部存儲爲768 MB ..但仍然同樣的問題..請suggess我 –

3

看看我對這個post的回答,有一個教程來做地圖v2在android模擬器上工作。

或者只是尋找genymotion

1

其在我的情況下工作很好。

我加入裏面的應用程序標記這個代碼清單

<meta-data 
     android:name="com.google.android.gms.version" 
     android:value="4242000" /> 
相關問題