android - 加载 map 失败。在 fragment 上联系 Google 服务器时出错

标签 android google-maps

  1. 我用谷歌搜索了两天,仍然是这条消息。我使用调试键进行调试 在我的 Nexus 7 上。
  2. 我不知道哪里错了。我有正确的 key ,打开正确的 api 访问权限
  3. 但我平板电脑上的谷歌地图仍然空白。

map fragment :

    public View onCreateView(LayoutInflater inflater, ViewGroup container,

Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.map_fragment,container, false); container.removeAllViews(); map = ((SupportMapFragment)getActivity() .getSupportFragmentManager() .findFragmentById(R.id.map)) .getMap(); map.setMyLocationEnabled(true); map.setMapType(GoogleMap.MAP_TYPE_NORMAL);

   mMapFragment = SupportMapFragment.newInstance();
   FragmentTransaction fragmentTransaction = 

getChildFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.map,mMapFragment);
fragmentTransaction.commit(); return rootView; }

list :

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="16" />

<!-- Google Map -->   <permission
      android:name="com.jertt.xxx.permission.MAPS_RECEIVE"
      android:protectionLevel="signature"/>
<uses-permission android:name="com.jertt.yummymap.permission.MAPS_RECEIVE"/>

<!-- end -->

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

<!-- end -->
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.jertt.yummymap.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>

    <!-- Google Map API Key -->

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

    <!-- end -->
</application>

map fragment .xml

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

最佳答案

不确定这是否是您的问题,但我花了很多时间试图解决这个问题。检查权限,重新生成 api key 。终于在另一个对我有用的答案中看到了一条小评论。

重命名您的 debug.keystore 文件,然后进行清理,然后构建。这将生成一个新的 debug.keystore。和一个新的 SHA1 指纹。将该新指纹插入 api 控制台并重试。

您可以检查的另一件事是查看您尝试从中访问 api 的项目的 api 控制台的“报告”部分。如果您已尝试运行您的项目并且没有该 api 的流量,则可能是 SHA1 指纹或您提供的包名称错误。在我的例子中是指纹。

关于android - 加载 map 失败。在 fragment 上联系 Google 服务器时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17849329/

相关文章:

android - 预期 @HiltAndroidApp 具有值。您是否忘记应用 Gradle 插件?

java - 无法实例化 Activity ComponentInfo{ProductSimpleInfoActivity} NullPointerException

Java字符串替换所有[url]

android - 当前位置未在 android 中拾取

android - "ERROR: Cannot recover key"使用现有 keystore 导出签名的 Android 应用程序时

java - 在Gradle中,在Android上,Storm注释处理器可以像AndroidAnnotations处理器一样运行吗?

javascript - GMaps JS 地理编码 : Using/Passing Variables With Asynchronous Geocode Function?

android - 为什么谷歌地图相机不在我的位置?

javascript - 如何最好地将微数据包含在动态 map 的 SVG 中?

javascript - 使用谷歌地图 API v3 的地点名称坐标