2013-07-12 37 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" />