无法使用Android Google Map V2 [英] Having Trouble Using Android Google Map V2

查看:72
本文介绍了无法使用Android Google Map V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法在Android应用中使用Android谷歌地图v2请看看,让我知道我在哪里做错了..



以下是我的代码MainActivity.java



Not able to use android google map v2 in android app please have look and let me know where i am doing wrong..

Following is the Code for my MainActivity.java

package com.example.googlemapv2;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;

public class MainActivity extends Activity {

	// Google Map

	private GoogleMap googleMap;

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

		try {
			initializeMap();

		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	@SuppressLint("NewApi")
	private void initializeMap() {
		if (googleMap == null) {
			googleMap = ((MapFragment) getFragmentManager().findFragmentById(
					R.id.map)).getMap();

		}
		if (googleMap == null) {

			Toast.makeText(getApplicationContext(),
					"Sorry, Unable to Show Map", Toast.LENGTH_SHORT).show();
		}
	}

	@Override
	protected void onResume() {
		
		super.onResume();
		initializeMap();

	}

}



和AndroidManifest.xml:






And AndroidManifest.xml:


<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    package="com.example.googlemapv2"
    android:versionCode="1"
    android:versionName="1.0" &gt;



    <uses-sdk>
        android:minSdkVersion="8"
        android:targetSdkVersion="14" /&gt;

    <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" />

    &lt;!-- Required to show current location --&gt;

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

    &lt;!-- Required OpenGL ES 2.0. for Maps V2 --&gt;
    <uses-feature>
        android:glEsVersion="0x00020000"
        android:required="true" /&gt;

    <application>
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" &gt;
        <activity>
            android:name=".MainActivity"
            android:label="@string/app_name" &gt;
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        &lt;!-- Google Map Key --&gt;

        &lt;meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyAxgtuqq30RxWs0jUtq8X6BNgbA1bkehUY" &gt;
        &lt;/meta-data&gt;
    </application>

</uses-feature></uses-sdk></manifest>

推荐答案

使用ADB install命令安装 com.android.vending-1。需要在模拟器中配置的apk com.google.android.gms-1.apk



关注这些链接,以防您遇到任何问题,



http://umut.tekguc.info/en/content/google-android-map-v2-step-step [ ^ ](步骤7以后)< br $> b $ b

http://nemanjakovacevic.net/blog/english/2012/12/06/how-to-make-android-google-maps-v2-work-in-android-模拟器/ [ ^ ]
Use the ADB install command to install com.android.vending-1.apk and com.google.android.gms-1.apk which needs to be configured in the Emulator.

Follow these links in case you face any issues,

http://umut.tekguc.info/en/content/google-android-map-v2-step-step[^] ( Step 7 onwards )

http://nemanjakovacevic.net/blog/english/2012/12/06/how-to-make-android-google-maps-v2-work-in-android-emulator/[^]


这篇关于无法使用Android Google Map V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆