Google MapActivity not displaying map

谁都会走 提交于 2019-12-25 08:58:19

问题


I am trying to get google maps working. It is not displaying the map. I get the following error in LogCat

Couldn't get connection factory client

I have been through all the duplicate posts, and made the following changes

  • Ensured that uses-permission and uses-library are inside tag
  • used debug.keystore instead of custom
  • signed up with google maps using my private key, and updated my MapView with the maps key in the xml (for this public post, I have changed it)
  • Exported my app, and used debug.keystore to build it

I am running it on emulator. Maps on emulator works.

Android Manifest

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <uses-library android:name="com.google.android.maps" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <activity
        android:name=".MyActivity"
        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=".GetLocation" android:label="@string/app_name"/>
</application>

location.xml

<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:clickable="true"
    android:apiKey="0psLgKtDQLB35-XJXUrjR4bKHIBDRuHu-O-xVhg"
    android:id="@+id/location"
/>

sudo keytool -list -alias androiddebugkey -storepass android -keypass android -keystore     debug.keystore 

returns

androiddebugkey, 20 Mar, 2012, PrivateKeyEntry, 
Certificate fingerprint (MD5): 20:D3:54:D9:F8:70:17:A4:BA:21:5C:98:88:27:45:E0

Fixed I put uses-permission outside of Application tag And uses-library inside of Application tag


回答1:


uses-permission outside the <application> Tag. and

Couldn't get connection factory client

And its map-api key problem .And you should create Fresh Map-api key .




回答2:


I believe you might have got the solution for this question but for anyone else looking for the help for same question here's the ans

try to put

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

outside your application tag

just leave <uses-library android:name="com.google.android.maps" /> inside the tag

add metadata inside the application tag as

<meta-data android:name="com.google.android.maps.v2.API_KEY"
android:value="your API key"/>

and it will definitely work fine



来源:https://stackoverflow.com/questions/10562824/google-mapactivity-not-displaying-map

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!