【问题标题】:Still Gets "Couldn't get connection factory client" Error仍然出现“无法获取连接工厂客户端”错误
【发布时间】:2013-04-01 05:13:43
【问题描述】:

04-01 10:17:20.701:E/MapActivity(377):无法获取连接工厂客户端

我得到的只是灰色瓷砖,地图没有加载。

嘿,我认识的每个人都有很多类似的帖子,我已经彻底阅读了它们。

可以是网络权限(我在应用标签前加了),或者

uses-library android:name="com.google.android.maps" (添加在应用程序标签内)或

这是错误的 API 密钥。

这是我之前创建的调试密钥,Google map api v1 可以正确显示地图,没有问题。 后来当我打开那个项目时,它没有解析 MapActivity、GeoPoint、MapController 等。

所以我创建了另一个调试密钥,我现在在这个项目上使用它,我仔细检查了我在创建 api 时是否正确执行了所有步骤。

这是(我在旧的基础上创建了一个新的调试)导致了这个问题吗?我应该删除 C:\Users\abc.android 中的 debug.keystore 并调试项目以自动创建一个新的吗?它会解决问题还是会导致我遇到更多问题?

从昨天开始,我一直在寻找解决方案,但问题仍然存在,请帮助我。非常感谢您,如果需要任何代码,请告诉我,我会发布它们。

MActivity.java

package com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;


import android.os.Bundle;

public class MActivity extends MapActivity {


    MapController mControl;
    GeoPoint GeoP;
    MapView mapV;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map);

        mapV =(MapView)findViewById(R.id.mapView);
        mapV.displayZoomControls(true);
        mapV.setBuiltInZoomControls(true);

        double lat = 6.796396;
        double longi = 79.877823;

        mControl = mapV.getController();

        GeoP = new GeoPoint((int)( lat * 1E6 ),(int)( longi * 1E6 ));
        mControl.animateTo(GeoP);
        mControl.setZoom(13);


    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }

}

map.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/layoutbg"
    android:orientation="vertical" >

   <com.google.android.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:apiKey="AIzaSyCy32DkrrrrT-UBhoT8xiAW182qUaAqi3s"
        android:enabled="true"
        android:clickable="true" />

</RelativeLayout>

清单

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

    <uses-sdk
        android:minSdkVersion="10"
        android:targetSdkVersion="17"/>


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


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

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

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



    <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.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.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="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.MenuActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.KCLOGO" />

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


        <activity
            android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.AddFromContactsActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.ADDFROMCONTACT" />

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


        <activity
            android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.MActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.MAPS" />

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


        <activity
            android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.LoginActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.LOGIN" />

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


        <activity
            android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.SignupActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.SIGNUP" />

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


        <activity
            android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.AddToContactsActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.Aws0mEKCkreaTi0ns.GlobAlpSystracKerKC.ADDTOCONTACTS" />

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

        <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="AIzaSyCy32DkrrrrT-UBhoT8xiAW182qUaAqi3s"/>

    </application>



</manifest>

【问题讨论】:

  • 您是否使用 API 2 的调试密钥并在代码中使用 MapActivity?如果您正在使用 API 2,您可能还需要更新您的代码。在此处发布一些代码。
  • 嗨 @DivyaMotiwala 感谢您的快速回复。是的,早些时候我使用 Fragment 显示地图并且我强制关闭,我知道我仍然可以使用地图查看和显示地图,所以我切换回使用 mapActivity。

标签: android google-maps google-maps-android-api-2


【解决方案1】:

我猜你混合了一些 V1 和 V2 功能(例如在清单中使用 &lt;uses-library android:name="com.google.android.maps" /&gt; 和使用 GeoPoint 等。(https://groups.google.com/forum/?fromgroups=#!topic/android-developers/CGF5X1HMLuY

试试下面的示例代码:

MActivity.java

   public class MActivity extends FragmentActivity{

private GoogleMap map;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);

        map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                .getMap();

        double lat = 6.796396;
        double longi = 79.877823;
        final LatLng HAMBURG = new LatLng(lat,longi);
        Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
                .title("Hamburg"));
        map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));


    }

地图.xml

   <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=".MapsActivity" >

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

从清单中删除 <uses-library android:name="com.google.android.maps" />

【讨论】:

  • 嘿,谢谢您的回复,我尝试了您的建议,但在“GoogleMap”和“SupportMapFragment”上出现“无法解析输入”错误我确实添加了 google-play-services_lib 文件-> import->existing android into workspace and Project->properties->android->add->google-play-services_lib 当我第一次添加库引用时它显示绿色勾号但是当我关闭它并再次转到 Project->properties -> 添加 google-play-services_lib 的 android 显示为红色叉号是问题吗?
  • 是的..我猜它没有正确导入。你应该引用你复制到源代码树的库的副本,你不应该从 Android SDK 目录引用库(比如复制项目导入时进入工作区)。您还需要为SupportMapFragment添加google-support-v4库。
  • google-support-v4.jar 已经在 lib 文件夹中...我会再次尝试引用并让您知道谢谢。
  • 非常感谢您的时间和精力。
  • 我会选择您的答案作为接受,因为您首先指出我使用 SupportFragmentManager。 :)
【解决方案2】:

在模拟器上运行google map v2有几个步骤,所以我准备了一步一步的教程来展示如何在模拟器上使用google map android v2(android 4.2.2)看看我的博客:http://umut.tekguc.info/en/content/google-android-map-v2-step-step

【讨论】:

  • 非常感谢您的时间和精力感谢它
【解决方案3】:

其实我一直在添加一个不同项目的.jar文件&This帮助我正确的添加了一个外部.jar到项目中。现在我没有得到“未解析类型”的错误..谢谢大家的指点我朝着正确的方向前进,你们人真棒。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-13
    • 2012-01-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多