使用Google Map的API V2碎片地图进行缩放控制的空白地图:

时间:2013-01-22 18:47:13

标签: android google-maps-android-api-2

我想使用新的谷歌地图api v2实施谷歌地图,由于某种原因我看不到地图。

我认为当我在模拟器上运行时,问题就是那两行错误:

 E/ActivityThread( 1373): Failed to find provider info for com.google.settings
 E/ActivityThread( 1373): Failed to find provider info for com.google.android.gsf
.gservices

当我在设备上运行应用程序时,会产生以下错误:

Could not find class 'maps.j.k', referenced from method map.y.ae.a

我的问题看起来与此链接相同:http://android-er.blogspot.co.il/2012/12/google-maps-android-api-v2-with-blank.html

有人说问题可能是我的关键,所以我使用以下教程复制了它:http://android-er.blogspot.co.il/2012/12/displaying-sha1-certificate-fingerprint.html。但这仍然没有帮助我。

支持文件当然会添加到项目以及Google Play服务库中。 我在模拟器上看到相同的结果(手动添加允许在模拟器上使用谷歌地图v2的两个文件)以及运行android 2.2的motorola Defy。

也许我使用的是错误的debug.keystore?我在我的User.android文件夹中使用那个。如果是这样,我如何找到正确的文件?

编辑:我的eclipse说我的调试密钥在默认文件夹中。所以我重命名了debug.keystore文件并运行Eclipse以重新创建它。这导致生成一个新的SHA1密钥。我用它来创建一个新的Google Maps API v2密钥,但结果仍然相同。我仍然无法看到地图。

EDIT2:愚蠢的我,我选择了谷歌地图API V2而不是谷歌地图Android API V2。        这个问题可以关闭。感谢。

以下是所有代码文件:

的xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
 <fragment
    xmlns:map="http://schemas.android.com/apk/res-auto"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    map:cameraBearing="112.5"
    map:cameraTargetLat="-33.796923"
    map:cameraTargetLng="150.922433"
    map:cameraTilt="30"
    map:cameraZoom="13"
    map:mapType="normal"
    map:uiCompass="false"
    map:uiRotateGestures="true"
    map:uiScrollGestures="false"
    map:uiTiltGestures="true"
    map:uiZoomGestures="true" /> 
</LinearLayout>

Map Fragmentactivity类:

package com.eadesign.skygiraffefinalv2;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.GoogleMap;
import android.os.Bundle;
import com.google.android.gms.maps.*;
import android.widget.ImageView;
import android.widget.TextView;
public class Map extends android.support.v4.app.FragmentActivity
{
private GoogleMap map;


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

        if (GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext()) == 0)
        {
            map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        //  map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
        }
}}

清单文件:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.eadesign.skygiraffefinalv2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"  android:targetSdkVersion="17"/>
<permission android:name="com.eadesign.skygiraffefinalv2.permission.MAPS_RECEIVE" android:protectionLevel="signature"/>
<uses-permission android:name="com.eadesign.skygiraffefinalv2.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:allowBackup="true"
    android:icon="@drawable/sgicon90"
    android:label="@string/app_name"
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">       


    <activity
        android:name=".Map"
        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="My key"/>            
</application>

从logcat登录:

ent.category.LAUNCHER] flg=0x10000000 cmp=com.eadesign.skygiraffefinalv2/.Map u=
0} from pid 1362
W/WindowManager(  148): Failure taking screenshot for (246x410) to layer 21010
D/AndroidRuntime( 1362): Shutting down VM
I/ActivityManager(  148): Start proc com.eadesign.skygiraffefinalv2 for activity
com.eadesign.skygiraffefinalv2/.Map: pid=1373 uid=10046 gids={3003, 1015, 1028}
D/dalvikvm( 1373): Not late-enabling CheckJNI (already on)
D/dalvikvm( 1362): GC_CONCURRENT freed 99K, 77% free 483K/2048K, paused 1ms+1ms,
total 13ms
D/jdwp    ( 1362): Got wake-up signal, bailing out of select
D/dalvikvm( 1362): Debugger has detached; object registry had 1 entries
E/jdwp    ( 1373): Failed sending reply to debugger: Broken pipe
D/dalvikvm( 1373): Debugger has detached; object registry had 2 entries
E/Trace   ( 1373): error opening trace file: No such file or directory (2)
D/dalvikvm( 1373): GC_CONCURRENT freed 204K, 3% free 8264K/8519K, paused 89ms+6m
s, total 161ms
D/dalvikvm( 1373): WAIT_FOR_CONCURRENT_GC blocked 33ms
E/ActivityThread( 1373): Failed to find provider info for com.google.settings
E/ActivityThread( 1373): Failed to find provider info for com.google.settings
D/dalvikvm( 1373): GC_CONCURRENT freed 312K, 5% free 8471K/8839K, paused 82ms+10
5ms, total 268ms
E/ActivityThread( 1373): Failed to find provider info for com.google.android.gsf
.gservices
E/ActivityThread( 1373): Failed to find provider info for com.google.android.gsf
.gservices
D/dalvikvm( 1373): GC_CONCURRENT freed 227K, 4% free 8797K/9095K, paused 91ms+11
0ms, total 300ms
D/libEGL  ( 1373): Emulator without GPU support detected. Fallback to software r
enderer.
I/Choreographer( 1373): Skipped 54 frames!  The application may be doing too muc
h work on its main thread.
D/gralloc_goldfish( 1373): Emulator without GPU emulation detected.
D/libEGL  ( 1373): loaded /system/lib/egl/libGLES_android.so
I/ActivityManager(  148): Displayed com.eadesign.skygiraffefinalv2/.Map: +3s545ms
I/Choreographer( 1373): Skipped 75 frames!  The application may be doing too muc
 h work on its main thread.

1 个答案:

答案 0 :(得分:3)

在我的情况下,我选择 Google Maps API V2而不是 Google Maps Android API V2。改变之后问题就消失了。所以这段代码完全可以创建一个全屏谷歌地图,问题可以关闭。

感谢。