Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 谷歌地图只显示灰色背景,而不是地图_Java_Android_Google Maps - Fatal编程技术网

Java 谷歌地图只显示灰色背景,而不是地图

Java 谷歌地图只显示灰色背景,而不是地图,java,android,google-maps,Java,Android,Google Maps,我目前正在开发一个使用谷歌地图API v2的应用程序。但MapView只显示灰色背景、谷歌徽标和缩放按钮 以下是错误消息: 10-27 10:50:25.309: D/REQUEST(18335): Connection opened to:https://clients4.google.com/glm/mmap/api 10-27 10:50:25.309: D/REQUEST(18335): Open Connection 10-27 10:50:26.239: D/REQUEST(1833

我目前正在开发一个使用谷歌地图API v2的应用程序。但MapView只显示灰色背景、谷歌徽标和缩放按钮

以下是错误消息:

10-27 10:50:25.309: D/REQUEST(18335): Connection opened to:https://clients4.google.com/glm/mmap/api
10-27 10:50:25.309: D/REQUEST(18335): Open Connection
10-27 10:50:26.239: D/REQUEST(18335): DRD(24): 62|147
10-27 10:50:26.239: D/REQUEST(18335): Close
10-27 10:50:26.239: D/REQUEST(18335): Error processing: com.google.maps.api.android.lib6.b.d@409cf570 not retrying
10-27 10:50:26.239: D/REQUEST(18335): Retrying: com.google.maps.api.android.lib6.c.au@409b25b8
还有一个:

10-27 10:49:49.309: E/REQUEST(18335): In Error Mode
10-27 10:49:49.319: E/Google Maps Android API(18335): Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).
我的清单包含我的API密钥和各种权限:

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

    <permission
        android:name="de.hobbit.xmltest.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="de.hobbit.xmltest.permission.MAPS_RECEIVE" />

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

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <!-- Required to show current location -->
    <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_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

         <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="SOMEKEY" />

        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".SingleActivity"
            android:label="@string/title_activity_single" >
        </activity>
    </application>

</manifest>

我希望有人能发现我的错误


谢谢。

我用错了密钥库

我没有使用调试密钥库,而是使用了实际的密钥库

在eclipse中访问调试密钥库

1.进入窗口->首选项->Android->构建

2.复制SHA1指纹


3.使用调试密钥库在开发人员控制台中生成API密钥

切勿发布API密钥!你可以也应该扔掉它,生成一个新的。。。这就像在这里发布您的密码!顺便说一句,您应该始终以清单中的最新API级别为目标,而不是与您的min sdk相同。还要确保为密钥正确设置了包名…@WarrenFaith好的,明白了,这里没有API密钥;)应正确设置程序包名称这节省了我的时间。只想为Android Studio用户添加信息:您可以在~/.Android/debug.keystore访问调试密钥库。要读取sha1,可以使用以下命令(假设它在.android文件夹下运行):keytool-list-v-keystore debug.keystore如何更改灰色?