Android MapView - 调试 API 密钥下无法加载地图瓦片

3

我在Android开发中遇到了一些问题,即无法将瓦片加载到我的MapView中。我已经搜索并查看了类似的问题,但迄今为止没有找到解决方法。

我查看了这里的说明,并获取了我的调试API密钥。我已将其输入到我的MapView中。

我已经检查了我的仿真器和调试设备是否已连接到互联网。

我已经将我的清单文件中的Internet权限标记移到应用程序标记之前。

我不知道还有什么可以检查的。

我也不确定最好的开发方式是什么。似乎我无法使用正确签名的应用程序进行调试,因为调试密钥库需要相同的密码-android。这意味着每次我要做发布构建时,都必须更改密钥-这似乎非常脆弱!

有没有办法使用自己生成的地图API密钥开发和发布构建?

这是你需要查看的一些代码:

Main.xml:

<com.google.android.maps.MapView
    android:id="@+id/mapView" 
    android:layout_height="fill_parent" 
    android:layout_width="fill_parent"
    android:apiKey="??:??:??:??:??:??:??:??:??:??:??:??:??:??:??:??"
    />

AndroidManifest.xml:

<manifest 
xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0" 
package="com.my.package.name"
>

<uses-sdk android:minSdkVersion="3"></uses-sdk>

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />

<application 
    android:icon="@drawable/icon" 
    android:label="@string/app_name" 
    android:debuggable="true"
    >

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

    <uses-library android:name="com.google.android.maps" />

</application>
</manifest> 

任何帮助都将不胜感激。
1个回答

11

android:apiKey="??:??:??:??:??:??:??:??:??:??:??:??:??:??:??:??"

如果您在这里有冒号,可能是因为您误解了应该粘贴的内容。

这些冒号是签名密钥的MD5指纹。然后,您需要将这些内容粘贴到Google网站上的表单中,并获取实际的签名密钥,它看起来像:

android:apiKey="00yHj0k7_7vzHbUFXzY2j94lYYCqW3NAIW8EEEw"

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接