简体   繁体   English

使用Google Map API v2时应用程序上出现黑屏

[英]Blank screen on application while using Google Map API v2

Could not find class com.google.android.gms.location.internal.ParcelableGeofence, referenced from method gls.a 找不到方法gls.a引用的com.google.android.gms.location.internal.ParcelableGeofence类

is the error we are getting. 是我们得到的错误。 We tried changing the API key as well, but still the Same blank screen. 我们也尝试过更改API密钥,但仍然是相同的空白屏幕。

These are our XML files: 这些是我们的XML文件:

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

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

  <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, but are
     recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

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

    <uses-permission android:name="com.example.khanakhazana.permission.MAPS_RECEIVE" />

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

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

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



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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".Restaurants"
            android:label="@string/title_activity_restaurants" >
        </activity>
        <activity
            android:name=".Info"
            android:label="@string/title_activity_info" >
        </activity>

        <activity
            android:name=".Map"
            android:label="@string/title_activity_map" >


        </activity>
        <activity
            android:name=".Notify"
            android:label="@string/title_activity_notify" >
        </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="AIzaSyC5YXqw5gwVWvr7CLnL4fvvP0pc6MO1Oy4" />
    </application>

</manifest>

and: 和:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent" >

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

</RelativeLayout>

as per my understanding this issue is happening because of three reason 据我了解,此问题的发生是由于三个原因

Reasons 原因

1) first is lack of internet connectivity 1)首先是缺乏互联网连接

2) second is your google api key is missmatching 2)第二个是您的Google API密钥不匹配

3) third if key is ok then your provided package name during key generation is not exact same as your project package name 3)第三,如果密钥确定,则在密钥生成过程中提供的软件包名称与您的项目软件包名称不完全相同

Solutions 解决方案

for first you need to check your internet conncetion is working or not then you need to go further 首先,您需要检查您的互联网连接是否正常工作,然后再继续操作

for second and third you need to create key with proper steps If your using eclipse then 对于第二和第三,您需要使用正确的步骤创建密钥。

Eclipse-->windows-->Preferences-->Android-->Build you will get SHA key Eclipse-> windows->首选项-> Android-> Build您将获得SHA键

Use that SHA key to generate your android key 使用该SHA密钥生成您的android密钥

after pasting SHA key append your project package name by following symbol ";" 粘贴SHA键后,在项目包名称后添加符号“;”

for example 例如

YOR_SHA_KEY;YOUR_PROJECT_MAIN_PACKAGE_NAME then generate key finally you will get google map key for android use that one hope it will resolve your problem make sure that your using same pakcage name which is your project package name YOR_SHA_KEY; YOUR_PROJECT_MAIN_PACKAGE_NAME然后最终生成密钥,您将获得android的google map密钥,希望它能解决您的问题,请确保您使用的包名称与您的项目包名称相同

hope it will solve your problem happy coding :) 希望它能解决您的问题快乐编码:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM