谷歌地图api关键android错误

时间:2015-06-16 13:43:12

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

我在使用GoogleMap API时遇到问题,我认为我的应用程序找不到我的api_key(请参阅日志),而我在代码中编写它。 MapView在几秒钟内打开并崩溃。在Google API网站中,我启用了Geocoding api,google place for android,google maps for android。

我的 Manifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="fr.mapeche.testnav1" >
    <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 ACCESS_COARSE/FINE_LOCATION 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" />

    <application
    android:allowBackup="true"
    android:icon="@drawable/ic_prises"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >

    <activity
        android:name=".view.MainActivity"
        android:configChanges="keyboardHidden|orientation|screenSize"
        android:label="@string/app_name"
        android:uiOptions="splitActionBarWhenNarrow" >

        <!-- configChanges Permet de ne pas perdre les données lors de la rotation d'écran -->
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MapsActivity"
        android:label="@string/title_activity_maps" >
    </activity>
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="@string/google_maps_key" />//The wright API_KEY
</application>

日志的一部分:

06-16 15:30:00.944  10741-10852/? E/MDM﹕ [24597] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}
06-16 15:30:00.986  10741-10855/? E/MDM﹕ [24598] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}
06-16 15:30:01.077  736-840/? E/WifiStateMachine﹕ WifiStateMachine CMD_START_SCAN source 10007 txSuccessRate=0,00 rxSuccessRate=0,00 targetRoamBSSID=00:23:69:93:39:66 RSSI=-69
06-16 15:30:01.105  736-840/? E/WifiStateMachine﹕ WifiStateMachine CMD_START_SCAN source 10007 txSuccessRate=0,00 rxSuccessRate=0,00 targetRoamBSSID=00:23:69:93:39:66 RSSI=-69
06-16 15:30:02.405  9811-9811/fr.mapeche.testnav1 E/DatabaseHelper﹕     SELECT * FROM fishing ORDER BY fishing_date DESC
06-16 15:30:07.538  11045-11154/? E/SQLiteLog﹕ (283) recovered 12 frames from WAL file /data/data/com.google.android.gms/databases/playlog.db-wal
06-16 15:30:09.162  11212-11212/? E/GmsWearableLS﹕ GoogleApiClient connection failed: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}
06-16 15:30:09.177  11212-11296/? E/MDM﹕ [24645] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}
06-16 15:30:09.268  11212-11308/? E/MDM﹕ [24649] b.run: Couldn't connect to Google API client: ConnectionResult{statusCode=API_UNAVAILABLE, resolution=null}

1 个答案:

答案 0 :(得分:0)

我有这个问题,我发现连接是问题所在。您必须创建两个凭据(一个用于调试,另一个用于发布版本)并将它们放到合适的google maps api xml文件中,然后API将不是您的问题。你必须检查连接或其他事情。