【问题标题】:Android Couldn't get connection factory clientAndroid 无法获取连接工厂客户端
【发布时间】:2014-01-02 08:36:59
【问题描述】:

好的,所以我有一个正在运行的应用程序,我正在 2 个基于 API 8 和另一个基于 API 11 的 Android 模拟器中进行测试。该应用程序在 API 11 中运行良好,但在 API 8 中由于无法获取而失败连接工厂客户端错误消息。

我想知道这是否与几件事有关

  • 也许我需要为不同的构建获取不同的 Google Maps API 密钥?
  • 也许我需要在我的 Manifest 文件中声明不同的声明才能使其适用于不同的构建?
  • 也许还有别的?

在项目属性中,我选择了作为 Google Maps API 8 的项目构建目标,并下载了我需要的所有适当的 SDK。

非常感谢您的任何帮助,感谢您的关注,同时这是我的清单文件...

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

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <uses-library android:name="com.google.android.maps" />

        <activity
            android:name="net.rogw.p352lbs.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>
    </application>

</manifest>

这是我的布局文件,我没有添加 java 文件,因为它很长,并且适用于 API 11 模拟器:-

<LinearLayout 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"
    android:orientation="vertical"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <com.google.android.maps.MapView
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:apiKey="Key is not shown here but it is a valid string"
        android:clickable="true"
        android:enabled="true" />

</LinearLayout>

【问题讨论】:

  • 您使用的是哪个 apiversion api v1 或 api v2?。看起来您正在使用已弃用的 api v1。
  • API V2 我认为但不确定我知道如何检查。
  • 我在应用程序标签中看不到元标签。你参考谷歌播放服务库项目吗? developers.google.com/maps/documentation/android
  • 同时发布您的活动代码和 xml 布局代码

标签: android client maps factory


【解决方案1】:

在您的 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"/>

【讨论】:

  • 你怎么知道 op 没有提到同样的事情?
  • 一般认为,大多数开发人员只会在这个问题上出错。这就是为什么我这样建议他
【解决方案2】:

您正在使用已弃用的 map api v1。您应该使用地图 api v2。

更改你的 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"/>

如果您想支持 api 级别 11 及以下,您将使用SupportMapFragment

您还需要在您的 android 地图项目中引用 google play services 库项目。

http://developer.android.com/google/play-services/setup.html

您的 Activity 类应该扩展 FragmentActivity

然后

你需要在应用标签内的meta标签中有api键。

在清单文件中您将需要更多权限

更多信息@

https://developers.google.com/maps/documentation/android/start#overview

删除

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

【讨论】:

  • 谢谢#Raghunandan,看来我还有工作要做。我现在就出发,到时候回来汇报。感谢您的意见,再次感谢。
猜你喜欢
  • 2012-01-22
  • 1970-01-01
  • 2011-01-13
  • 2013-09-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多