【问题标题】:How we test Google Map API v2 on emulator我们如何在模拟器上测试 Google Map API v2
【发布时间】:2013-07-10 15:57:18
【问题描述】:

我使用 v2 Version 实现了 Google Map。我在真实设备上测试了应用程序。它工作正常,但我也想在模拟器上测试它。我该怎么做?

这是我的 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;
    }

}

【问题讨论】:

  • 我建议你在真机上测试一下。
  • @Raghunandan 我在真实设备上测试它工作正常,但我也想测试它模拟器
  • 您可以查看此解决方法blog-emildesign.rhcloud.com/?p=527。但是如果您已经在设备上进行了测试,为什么还要在模拟器上进行测试呢?用户在真实设备上而不是在模拟器上使用您的应用程序。所以如果它可以在设备上运行,我不会太担心模拟器
  • 因为我没有个人设备,我必须开发完全基于地图的应用程序。
  • 使用 Google API 模拟器

标签: android map


【解决方案1】:

这个问题我也纠结了很久。我没有一台Android设备可以使用,所以我必须在模拟器上尝试。

我发现让地图在模拟器上运行的最佳方法是使用另一个模拟器而不是 eclipse 模拟器。

搜索Genymotion。是我试过的最好的模拟器。您可以使用 google play 下载任何应用程序,并且地图可以正常工作。

对不起,我的英语不好。

【讨论】:

    【解决方案2】:

    Google map api 2 不支持在 android 中运行。它Refer this,但是您可以在模拟器中安装一些 apk 以访问模拟器中的 google map api v2 see here

    【讨论】:

    • 我点击此链接 .. 但我没有得到任何解决方案 .. 当我尝试推送 vending.apk 时。发生错误“设备中没有更多空间”现在我如何解决这个问题
    • 这是由于模拟器中可用的存储空间较少。卸载您在模拟器中安装的无用应用程序,并通过在 AVD 管理器中编辑您的模拟器来增加您的内部存储空间。
    • 我将内部存储更改为 768 MB .. 但还是同样的问题 .. 请给我建议
    • 你在改变 RAM 内存大小吗?您需要更改内部存储。
    【解决方案3】:

    看看我在这个post 上的回答,有一个教程可以在安卓模拟器上制作地图 v2。

    或者只是寻找genymotion

    【讨论】:

      【解决方案4】:

      在我的情况下它工作正常。

      我已经在 Manifest 的应用标签内添加了这段代码

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

      【讨论】:

        【解决方案5】:

        你就是做不到。模拟器目前不支持地图 V2。

        【讨论】:

        猜你喜欢
        • 2013-08-29
        • 2016-04-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-10-30
        • 1970-01-01
        • 1970-01-01
        • 2012-12-11
        相关资源
        最近更新 更多