Android的谷歌地图API V2空白屏幕 [英] Android Google Map API V2 Blank Screen

查看:218
本文介绍了Android的谷歌地图API V2空白屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我最近跟着Vogella对谷歌地图API第2版的教程。在code是与他的相似。但由于某些原因在地图上显示了空白的和的logcat显示没有错误任。我也跟着这个影片得到SHA1指纹,然后我把清单文件中的API密钥。我用调试密钥库C:\ Users \用户UserName.android \ debug.keystore这也是默认的调试密钥库位于在Eclipse - > Windows版 - > preference - > Android的 - >构建

Hi I recently followed Vogella's tutorial on Google Map API v2. The code is similar to his. But for some reason the map shows up blank and the logcat shows no error either. I also followed this video to get the SHA1 finger print then I put the API key inside the manifest file. I used the debug keystore C:\Users\UserName.android\debug.keystore which is also the default debug keystore located in Eclipse -> Windows -> Preference -> Android -> Build.

我也产生了一个新的API密钥,它仍然无法正常工作。

I also generated a new API key and it still doesn't work.

清单文件:

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

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

    <permission
        android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <uses-feature android:name="android.hardware.camera.flash" />

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.SET_DEBUG_APP"></uses-permission>
    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".HomeActivity"
            android:label="@string/title_activity_home" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

        </activity>
        <activity android:name=".ScanActivity"/>
        <activity android:name=".MapActivity"/>
        <activity android:name=".BarcodeHelper"/>
        <activity android:name=".JsonHelper"/>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="my api key" />
    </application>

</manifest>

这是我的地图活动的布局文件:

This is my layout file for the map activity:

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapActivity" >

        <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.MapFragment" />

</RelativeLayout>

这是我的地图活动:

谢谢!

推荐答案

您有几个权限问题与你的清单。首先,在下面你需要用你的包取代的包名,您还需要为使用-许可

You have couple of permission issues with your manifest. First, in the following you need to replace the package name with your package, you also need to as a uses-permission

 <permission
        android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

根据你的包名,应该是 -

per your package name, should be --

<permission
          android:name="com.example.barcodelibrary.permission.MAPS_RECEIVE"
          android:protectionLevel="signature"/>
<uses-permission android:name="com.example.barcodelibrary.permission.MAPS_RECEIVE"/>

最后,你似乎缺少从<一个下列权限href="https://developers.google.com/maps/documentation/android/start#specifying_permissions">specifying在的权限部分入门指南 -

Finally, you seem to be missing the following permissions from the specifying permissions section of the Getting Started guide --

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

这篇关于Android的谷歌地图API V2空白屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆