1

我正在尝试使用新的谷歌地图 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 的摩托罗拉 Defy 上看到了相同的结果。

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

编辑:我的日食说我的调试密钥在默认文件夹中。所以我重命名了 debug.keystore 文件并运行 Eclipse 重新创建它。这导致产生了一个新的 SHA1 密钥。我用它创建了一个新的 Google Maps API v2 密钥,但结果还是一样。我还是看不到地图。

EDIT2:愚蠢的我,我选择了 Google Map API V2 而不是 Google Maps 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>

地图片段活动类:

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.
4

1 回答 1

3

就我而言,我选择了Google Maps API V2 而不是Google Maps Android API V2。改了之后问题就没有了。因此,此代码非常适合创建全屏 Google 地图,并且可以关闭问题。

谢谢。

于 2013-02-02T18:22:56.050 回答