Android:MapView 仅显示灰色网格,错误为 "Couldn' t get connection factory client”

标签 android google-maps android-mapview

在过去的几天里,我一直无法让简单的 MapView 正常工作,没有覆盖任何东西,只有 map 。我查找了很多解决方案,但没有一个对我有用。

我有一个用于调试 keystore 的 apikey。我在 list 文件中的适当位置拥有所有适当的权限,但我仍然遇到相同的错误和相同的灰色网格。我的代码中缺少什么吗?我不知道出了什么问题,请帮忙!

这是 mapactivity 的布局 xml:

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

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:enabled="true"
        android:clickable="true"
        android:apiKey="xxxx" />

</LinearLayout>

这是 map Activity 代码:

public class MapActivity extends com.google.android.maps.MapActivity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map_view);  
    }

    @Override
    protected boolean isRouteDisplayed() {
        return false;
    }
}

这是我的 list 文件:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="xxxx"
    android:versionCode="1"
    android:versionName="1.0" >

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

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

    </application>

</manifest>

最佳答案

通过使用 SHA1 证书指纹,我遇到了同样的问题。所以我选择了 MD5 证书指纹。进入本站https://developers.google.com/maps/documentation/android/v1/maps-api-signup并给你 MD5 指纹并获得 key 。 获取MD5指纹

  1. 在运行中输入 cmd 打开命令提示符。开始 ⇒ 运行 ⇒ 输入 cmd
  2. 输入 cd c:\path-to-jdk-dir\bin\进入 jdk 的 bin 目录 在我的例子中,我输入了 cd C:\Program Files\Java\jdk1.7.0_07\bin\
  3. 然后键入 keytool -exportcert -alias androiddebugkey -keystore "C:\Users\用户名.android\debug.keystore"-list -v

    在我的例子中,我输入了 keytool -exportcert -alias androiddebugkey -keystore "C:\Users\User.android\debug.keystore"-list -v

  4. 然后您将被要求输入密码。默认密码是 android。
  5. 然后您将获得 MD5 指纹。

关于Android:MapView 仅显示灰色网格,错误为 "Couldn' t get connection factory client”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9567311/

相关文章:

android - 如何在滑动时显示和隐藏 View

google-maps - 谷歌地图矩形可编辑 : how to lock (fixed) height from editing

xcode - 未找到框架 GoogleMapsCore 错误

android - 如何从 Overlay onTap 方法将按下的位置返回到 MapActivity

android - 使用 Json 在 Google map Mapview 中绘制路径

android - Mapview 仅在底部 android 显示谷歌 Logo

android - 将触摸事件传递给下面的应用程序

Java加密问题

java - 在照片上传期间,android 中的期望失败

javascript - Google map JavaScript-地点详细信息结果