0

我的谷歌地图有问题:没有地图出现,只有这样的白色地图图块:http: //oi47.tinypic.com/2uh0sk0.jpg

我试图生成一个新的 API 密钥,但它仍然不起作用,我不明白为什么......

这里是logcat:

04-02 11:04:07.459: W/dalvikvm(32502): VFY: unable to resolve virtual method 3693: Lcom/fullwipe/bolognacityguide/Mapexample;.getFragmentManager ()Landroid/app/FragmentManager;
04-02 11:04:07.499: W/dalvikvm(32502): VFY: unable to resolve instance field 23
04-02 11:04:07.859: W/dalvikvm(32502): Unable to resolve superclass of Lmaps/p/s; (425)
04-02 11:04:07.859: W/dalvikvm(32502): Link of class 'Lmaps/p/s;' failed
04-02 11:04:07.859: W/dalvikvm(32502): Unable to resolve superclass of Lmaps/y/bo; (3818)
04-02 11:04:07.859: W/dalvikvm(32502): Link of class 'Lmaps/y/bo;' failed
04-02 11:04:07.859: W/dalvikvm(32502): Unable to resolve superclass of Lmaps/i/k; (4206)
04-02 11:04:07.859: W/dalvikvm(32502): Link of class 'Lmaps/i/k;' failed
04-02 11:04:07.859: E/dalvikvm(32502): Could not find class 'maps.i.k', referenced from method maps.z.ag.a
04-02 11:04:07.859: W/dalvikvm(32502): VFY: unable to resolve new-instance 3538 (Lmaps/i/k;) in Lmaps/z/ag;
04-02 11:04:09.449: E/Adreno200-ES20(32502): **** 32547: glUseProgram(0)
04-02 11:04:10.109: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 0
04-02 11:04:10.109: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:10.119: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 1
04-02 11:04:10.119: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:11.869: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 0
04-02 11:04:11.949: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:11.979: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 1
04-02 11:04:11.999: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:12.069: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 0
04-02 11:04:12.089: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:12.199: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 1
04-02 11:04:12.199: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:12.239: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 0
04-02 11:04:12.249: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE
04-02 11:04:12.279: E/Adreno200-EGLSUB(32502): Enter: GetBackBuffer(), surface: 0x2ca458, bufid: 1
04-02 11:04:12.299: E/Adreno200-EGLSUB(32502): Return: GetBackBuffer(), TRUE

显现:

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

    <uses-sdk android:minSdkVersion="9"
                android:targetSdkVersion="16" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.CAMERA" />
  <uses-feature android:name="android.hardware.camera" 
                android:required="false"/>
  <uses-feature android:name="android.hardware.camera.any"
                android:required="false" />

  <permission android:name="com.kurtis.myapp.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
  <uses-permission android:name="com.kurtis.myapp.permission.MAPS_RECEIVE"/>
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
  <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:icon="@drawable/icona"
        android:label="@string/app_name" >
        <activity
            android:name="com.kurtis.myapp.Home"
            android:label="@string/app_name"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.kurtis.myapp.Mapexample"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:screenOrientation="portrait" >
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaXXXXXXXXXXXXXXXXXXXXXXXXXq9M" />
    </application>

</manifest>

活动:

package com.kurtis.myapp;

import com.example.android.R;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.SupportMapFragment;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class Mapexample extends FragmentActivity {
    private GoogleMap mMap;

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

        mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);

    }


    private void setUpMapIfNeeded() {
        // Do a null check to confirm that we have not already instantiated the map.
        if (mMap == null) {
            mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
            // Check if we were successful in obtaining the map.
            if (mMap != null) {
                // The Map is verified. It is now safe to manipulate the map.

            }
        }
    }
}

布局:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/map"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 class="com.google.android.gms.maps.SupportMapFragment"/>

你有解决这个问题的想法吗?

4

4 回答 4

2

您在 android 清单文件中的包名称有问题:

检查这个:

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

<permission android:name="com.kurtis.myapp.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
  <uses-permission android:name="com.kurtis.myapp.permission.MAPS_RECEIVE"/>

将其更正为相同。

您已经添加了不同的权限,MAPS_RECEIVE然后它如何接收地图?将其更改为

<permission android:name="com.example.android.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
      <uses-permission android:name="com.example.android.permission.MAPS_RECEIVE"/>
于 2013-04-02T10:38:13.917 回答
0

在 Google API 控制台中,确保您已打开“Google Maps Android API v2”服务,而不仅仅是“Google Maps API v2”服务。

于 2013-06-26T00:40:49.733 回答
0

当您生成 API 密钥时,请确保您也在 DEBUG 模式下这样做。
我想,这就是你问题的根本原因。

您将需要两个单独的密钥;一个用于 DEV(在模拟器等中使用的未签名应用程序)
和一个用于 LIVE(在签署您的应用程序时使用)。

于 2013-04-02T10:11:44.730 回答
0
  1. :com.kurtis.myapp你在 Manifest 中的包名不应该是com.example.android

  2. 尝试class="com.google.android.gms.maps.MapFragment"在您的布局中使用

  3. 在您的主要活动中使用 Activity 而不是 FragmentActivity 并替换
    mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap(); mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);

    有了这个:

    mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)) .getMap(); mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);

希望这有帮助

于 2013-04-02T10:41:28.740 回答