Android MapView:Couldn't find the connection factory client

狂风中的少年 提交于 2019-12-08 05:59:43

问题


As I know, that question is discussed so many time here, but still as I tried I faced the same issue and did all try what I saw here and also by Google but still that issue is unresolved.

Also, I tried the sample codes from so many sites and there also the same problem.(Issue that on MapActivity derived class, I can see the grid but map not loading while threw aforesaid exception)

I tried with my own API key as well as the keys already present in the sample code. And, also tried in device with keeping Location option enable and disable both.

Please do provide me your assistance.

Below is used one manifest file...

**

<permission
      android:name="com.Example.appl.permission.MAPS_RECEIVE"
      android:protectionLevel="signature"/>

<uses-permission android:name="com.Example.appl.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

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

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


    <activity
        android:name="com.Example.appl.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=".MHomeActivity"></activity>





</application>

**


回答1:


Finally, after messing two days, I got the solution still if someone has best please update me.

What I did, after reviewing so many threads and links, I got to know that nothing is wrong with above code/manifest, so I dig into the Google Map API key and below solution see me the way...(Please note that I'm doing my development over mac).

First of all I open my terminal and at there I accessed at Java folder and within it bin folder, then type following beneath command :-

***keytool -list -alias androiddebugkey -keystore \User\.android\debug.keystore -storepass android -keypass android***

Please note that in above command "\User.android\debug.keystore" This is the path where your android debug key is kept, in case in eclipse if you want to find that path(may be it's different on your system), use following:

**eclipse->window->preferences->Android->Build** 

So, when you run above command, you'll find the MD5 key and then you need to access following link:-

https://developers.google.com/maps/documentation/android/v1/maps-api-signup

Here, at beneath you'll give above obtained MD5 key and it'll generate api key for you for debug. That's all then supply this api key either at required xml or coding(Depends how you code).

But this provision is for v1. If someone found a way for v2, please update this thread.




回答2:


Check wether you have added the map library in android-manifest file inside Application tag.

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



回答3:


I searched your problem I have the solution and given below please refer these...

Couldn't get connection factory client in logcat

Couldn't get connection factory client




回答4:


After read and browse a lot the answer for use the API v2 even if you are develop for Android 2.2

Get the signature SHA1

keytool -list -alias androiddebugkey -keystore ~/.android/debug.keystore -storepass android -keypass android

get something like (SHA1): 82:73:C3:82:73:C3:82:73:C3:82:73:C3:82:73:C3:82:73:C3

Get API_KEY

Go to Google Api Console in Services set ON to Google Maps Api v2 later in Api Access section click on Create new Android Key or Update if you has one, put inside dialog

82:73:C3:82:73:C3:82:73:C3:82:73:C3:82:73:C3:82:73:C3;COM.PACKAGE.NAME

Add libraries

Add the google-play-services to your project, Go to Project properties -> Android in the section "Library" click Add and browse to sdk-android>/extras/google/google_play_services/libproject/google-play-services_lib.

Check for android-support-v4.jar library in your Project dependencies.

Edit your code

<!--AndroidManifest.xml-->
<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="17" />
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<permission android:name="COM.PACKAGE.NAME.permission.MAPS_RECEIVE"></permission>
<uses-permission android:name="COM.PACKAGE.NAME.permission.MAPS_RECEIVE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

<!--inside <application> tag-->
<meta-data android:value="API_KEY" android:name="com.google.android.maps.v2.API_KEY"/>

in your Activity class your need extend from android.support.v4.app.FragmentActivity

//MainActivity.java

package COM.PACKAGE.NAME;    

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class MainActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}

and for last you need change your activity_main.xml

<!--./res/layout/activity_main.xml-->
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"/>


来源:https://stackoverflow.com/questions/14745850/android-mapviewcouldnt-find-the-connection-factory-client

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