【问题标题】:Google Map API v2 grey tiles, everything worked fine (code inside)Google Map API v2 灰色瓷砖,一切正常(内部代码)
【发布时间】:2014-05-23 18:14:40
【问题描述】:

一切正常,我唯一遇到的问题是,当我将城市更改为我所在国家/地区南部的某个地方时,我遇到了常见的“应用程序停止工作问题”,但这很好,我也认为这件事搞砸了当我尝试导出应用程序并填写密钥库字段等时。

我在谷歌上到处搜索,没有找到任何有用的东西,到目前为止我尝试过的所有解决方案都失败了。包含: - 仅使用地图从一开始就创建一个全新的项目。我仍然只有灰色瓷砖,没有地图。 (我也尝试使用 MapFragment 而不是 SupportMapFragment) - 我删除了 debug.keystore 甚至 default.keyset 并生成了几次 API 密钥,但仍然没有任何效果。

这是代码,但我认为它没有任何问题: 清单:

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

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

  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  <uses-permission android:name="android.permission.INTERNET"/>
  <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
  <!-- External storage for caching. -->
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
  <!-- My Location -->
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
  <!-- Maps API needs OpenGL ES 2.0. -->
  <uses-feature
    android:glEsVersion="0x00020000"
    android:required="true"/>

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

            <meta-data android:name="com.google.android.maps.v2.API_KEY"
                android:value="AIzaSyDMsGnxt0GrU7Se5arkExJ96uLKqJWmjcQ"/>
            <meta-data
                android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version" />

            <activity
                android:name="com.example.pfe.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>

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

            <activity
                android:name="com.example.pfe.Couverture"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>

    </application>

</manifest>

我在 MainActivity 的 onCreate() 方法中使用它检索地图

SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        googleMap = fm.getMap();
</code>

仍然需要一些尝试,但它正在工作。

布局是这样的。

<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/m1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnCount="1"
    android:orientation="horizontal"
    tools:ignore="NewApi" >

    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="458dp"
        android:layout_column="0"
        android:layout_gravity="left|fill_vertical"
        android:layout_row="2"
        class="com.google.android.gms.maps.SupportMapFragment" />

</GridLayout>

我只想按下编译按钮并让地图工作,所以如果有人可以提供任何帮助,我将非常感激!

【问题讨论】:

  • 我认为问题在于地图不是从谷歌的服务加载的,所以我也尝试更改包名并重新生成密钥。仍然没有地图!

标签: android eclipse google-maps map tiles


【解决方案1】:

问题解决了。

这是我为遇到此类问题的人所做的:我首先删除了项目并将其重新导入到 eclipse 中,完全重命名包,删除 debug.keystore 文件并重建项目以获取新项目然后重新生成一个新的 API 密钥并使用新的 SHA1 指纹将其放入我的清单中。 问题是我做了几次上述所有操作都没有成功,并决定暂时搁置它,并时不时地尝试运行它(不接触源代码),今天它只是工作了,所以也许 API 密钥需要一些是时候正常运行了。

如果您遇到同样的问题,请随时向我询问任何细节!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多