【问题标题】:android : google map working in tablet not in vmware why?android:谷歌地图在平板电脑上工作而不是在 vmware 为什么?
【发布时间】:2013-12-13 10:42:28
【问题描述】:

我是 Android 新手,我在 android 中有一个关于 google maps api 的项目,所以我按照官方网站教程(一步一步)学习如何绘制地图应用程序。 当然,我在 eclipse 默认模拟器(太慢)方面遇到了很大的问题,所以我在我的 vmware 中安装了 android,它工作正常,但是 该应用程序显示带有谷歌签名的黑色地图以及放大和缩小按钮,但是当我在朋友的平板电脑上测试它时,它工作得很好。 如果有人能帮忙,我会很感激的。

AndroidManifest.xml:

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

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

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

    <uses-permission android:name="com.example.mapexample.permission.MAPS_RECEIVE" />
    <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" />
    <!-- External storage for caching. -->
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <!-- My Location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

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

        <meta-data android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version"/>
        <activity
            android:name="com.example.mapexemple.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>
    </application>

</manifest>

Activity_main.xml:

    <RelativeLayout 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" xmlns:android="http://schemas.android.com/apk/res/android">
    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="600dp" />

    <EditText
        android:id="@+id/lng"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/map"
        android:layout_alignParentBottom="true"
        android:ems="10" android:inputType="text">

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/lat"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"   
         android:layout_below="@+id/map"     
        android:layout_alignParentBottom="true"
        android:layout_toRightOf="@+id/lng"
        android:ems="10"  android:inputType="text"
       />

    <Button
        android:id="@+id/btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         android:layout_below="@+id/map"
        android:layout_alignRight="@+id/map"
        android:layout_alignParentBottom="true"
        android:text="@string/find" />

</RelativeLayout>

MainActivity.java:

package com.example.mapexemple;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.example.mapexemple.R;

public class MainActivity extends FragmentActivity {

SupportMapFragment mMap;
GoogleMap googleMap;
Button btn;
EditText lngg;
EditText latt;
static final LatLng CasaVoyageur = new LatLng(33.589509,-7.590633);
private LatLng destination = null;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
     btn=(Button) findViewById(R.id.btn);
     lngg=(EditText)findViewById(R.id.lng);
     latt=(EditText)findViewById(R.id.lat);
    mMap = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    googleMap = mMap.getMap();

     btn.setOnClickListener(new View.OnClickListener() {



@Override
         public void onClick(View v) {
         destination=new LatLng(Double.parseDouble(lngg.getText().toString()),Double.parseDouble(latt.getText().toString())
        );
     googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
     destination, 18));
     googleMap.addMarker(new MarkerOptions().position(destination));
     System.out.println(destination.latitude);
     System.out.println(destination.longitude);
     }
         })
}
}

【问题讨论】:

  • 我采用了 google play services 项目并将其链接到我的应用程序项目,如教程所述,我还在我的 (android)vmware 中安装了 googple play,但它是否明确适用于 v2 我没有不知道!!!
  • 看起来身份验证有问题,您可以尝试什么,查看 logcat 以了解可能的错误,另外,从 vmware player 卸载应用程序,清理并重建您的项目并安装它。
  • 在你的manifest文件中&lt;meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="key" /&gt;key必须是你生成的api-key?
  • 是的,完全基于 sha1 调试密钥 + 包。我一步一步地按照步骤进行操作,我认为这不是原因。
  • 所以,请检查我的答案上的链接。

标签: android eclipse google-maps


【解决方案1】:

您不能在模拟器或虚拟设备上运行 google-maps。发现在这个link

【讨论】:

  • 这对我来说将是一个严重的问题,我真的买不起安卓手机或平板电脑。我不知道你是否听说过 genymotion 模拟器,我的同事说它工作正常但问题是我的 CPU 不支持虚拟化。
  • 我阅读了有关 genymotion 的文章并使用了一小会儿。它比 android 模拟器更好,人们说 genymotion 支持谷歌地图,但我从未尝试过。最后,不幸的是,模拟器是不可能的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多