1

我正在尝试为 android 设置谷歌地图。我看到两个缩放按钮,但没有显示地图。在过去的 6-7 个小时里,我一直在努力奋斗。早些时候它显示错误(没有打开),现在它没有显示地图。

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

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

<permission
    android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

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

<uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<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" />

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

    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="(mykey)" />
</application>

编辑:这是 LogCat 错误

  03-09 23:15:47.210: W/KeyCharacterMap(14440): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
03-09 23:16:24.740: W/dalvikvm(14545): VFY: unable to resolve instance field 23
03-09 23:16:25.540: W/dalvikvm(14545): Unable to resolve superclass of Lmaps/p/s; (427)
03-09 23:16:25.540: W/dalvikvm(14545): Link of class 'Lmaps/p/s;' failed
03-09 23:16:25.540: W/dalvikvm(14545): Unable to resolve superclass of Lmaps/y/bo; (3820)
03-09 23:16:25.540: W/dalvikvm(14545): Link of class 'Lmaps/y/bo;' failed
03-09 23:16:25.540: W/dalvikvm(14545): Unable to resolve superclass of Lmaps/i/k; (4208)
03-09 23:16:25.540: W/dalvikvm(14545): Link of class 'Lmaps/i/k;' failed
03-09 23:16:25.540: E/dalvikvm(14545): Could not find class 'maps.i.k', referenced from method maps.z.ag.a
03-09 23:16:25.540: W/dalvikvm(14545): VFY: unable to resolve new-instance 3540 (Lmaps/i/k;) in Lmaps/z/ag;
03-09 23:16:29.020: I/ActivityThread(14545): queueIdle
03-09 23:16:29.060: V/ActivityThread(14545): Reporting idle of ActivityRecord{4a4a9288 token=android.os.BinderProxy@4a4a8df8 {com.counz.app/com.counz.app.MainActivity}} finished=false
03-09 23:16:29.060: W/ActivityNative(14545): send ACTIVITY_IDLE_TRANSACTION
03-09 23:16:29.750: E/Google Maps Android API(14545): Authorization failure.
03-09 23:16:58.600: I/ActivityThread(14545): queueIdle
03-09 23:16:58.600: V/ActivityThread(14545): Reporting idle of ActivityRecord{4a4a9288 token=android.os.BinderProxy@4a4a8df8 {com.counz.app/com.counz.app.MainActivity}} finished=false
03-09 23:16:58.600: W/ActivityNative(14545): send ACTIVITY_IDLE_TRANSACTION

谢谢。:)

4

2 回答 2

2

您引用错误的方式,请查看我为在您的应用程序中获取 Google 地图而编写的这个简短的 8 步指南,请准确按照步骤操作,最后您将获得 Google 地图。

在编写本指南时,我正在创建一个 Google 地图应用程序,您可以在其末尾看到最终结果。

创建 Google Map API V2

于 2013-03-09T15:32:27.717 回答
1

Acrivity必须扩展FragmentActivity以进行适当的片段膨胀。请检查是否MainActivity扩展FragmentActivity。请记住,如果您为旧版本的 Android 编写应用程序,则必须使用支持库 v4 而SupportMapFragment不是MapFragment.

顺便提一句。在 Eclipse 中引用 android 库不会改变AndroidManifest.xml,只有project.properties. 您必须像这样手动添加行

<activity android:name="com.example.android.tictactoe.library.GameActivity" />

仅当您使用Activity图书馆中的一些时。在谷歌地图 v2 的情况下,您只需要MapFragment,所以您不必这样做。

于 2013-03-09T13:22:48.443 回答