Google Maps API v2突然停止工作

时间:2013-07-08 03:32:25

标签: android android-maps-v2

当Google Maps API v2突然停止工作时,一切都运行良好。经过整整1天1夜的尝试后,我仍然无法将它带回来。我做了一个简单的应用程序,它仍然无法正常工作。

我的文件如下:

package com.azimbunafar.apps.japanallthingsdirectory;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

    public class MapActivity extends FragmentActivity {

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

布局文件是

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

清单文件是:

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

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="17" />

    <permission
        android:name="com.azimbunafar.apps.japanallthingsdirectory.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.azimbunafar.apps.japanallthingsdirectory.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <!--
     The following two permissions are not required to use
     Google Maps Android API v2, but are recommended.
    -->
    <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="AIzaSyCzxLRmQvoRhtxVKHcaPAacknQfJVtXSoQ" />

        <activity
            android:name="com.azimbunafar.apps.japanallthingsdirectory.MapActivity"
            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>

我在LogCat中遇到的错误是

    07-08 12:28:29.114: D/dalvikvm(12232): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
07-08 12:28:29.114: W/dalvikvm(12232): VFY: unable to resolve instance field 27
07-08 12:28:29.114: D/dalvikvm(12232): VFY: replacing opcode 0x52 at 0x0012
07-08 12:28:29.114: D/dalvikvm(12232): VFY: dead code 0x0014-0018 in Lcom/google/android/gms/common/GooglePlayServicesUtil;.b (Landroid/content/res/Resources;)Z
07-08 12:28:29.394: D/dalvikvm(12232): GC_CONCURRENT freed 209K, 45% free 3134K/5639K, external 0K/0K, paused 6ms+26ms
07-08 12:28:29.954: D/dalvikvm(12232): GC_CONCURRENT freed 350K, 45% free 3332K/5959K, external 0K/0K, paused 2ms+7ms
07-08 12:28:30.365: D/dalvikvm(12232): GC_CONCURRENT freed 334K, 43% free 3539K/6151K, external 0K/0K, paused 2ms+4ms
07-08 12:28:30.435: D/libEGL(12232): loaded /system/lib/egl/libGLES_android.so
07-08 12:28:30.455: D/libEGL(12232): loaded /system/lib/egl/libEGL_adreno200.so
07-08 12:28:30.455: W/SchedPolicy(12232): add_tid_to_cgroup failed to write '' (Invalid argument); background=0
07-08 12:28:30.465: D/libEGL(12232): loaded /system/lib/egl/libGLESv1_CM_adreno200.so
07-08 12:28:30.475: D/libEGL(12232): loaded /system/lib/egl/libGLESv2_adreno200.so
07-08 12:28:30.585: D/dalvikvm(12232): GC_EXTERNAL_ALLOC freed 24K, 43% free 3548K/6151K, external 0K/0K, paused 50ms
07-08 12:28:31.056: D/dalvikvm(12232): GC_CONCURRENT freed 280K, 42% free 3663K/6279K, external 235K/512K, paused 2ms+3ms
07-08 12:28:31.216: I/Google Maps Android API(12232): Failed to contact Google servers. Another attempt will be made when connectivity is established.
07-08 12:28:31.606: E/Google Maps Android API(12232): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).

我搜索了“无法加载地图时的每个主题。错误联系Google服务器”错误。但似乎没有任何效果。

我将不胜感激任何解决方案或建议。如果您需要有关我的申请的更多信息,请告诉我。

1 个答案:

答案 0 :(得分:1)

您应该检查您的权限,我遇到了同样的问题,这是因为我删除了一个权限。请务必在清单中拥有所有这些权限。

 <uses-permission android:name="com.example.adroidtest.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--
 The following two permissions are not required to use
 Google Maps Android API v2, but are recommended.
-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

希望它对你有所帮助。