【问题标题】:com.google.android.maps.MapView, was not found in the project or the librariescom.google.android.maps.MapView,在项目或库中找不到
【发布时间】:2013-08-24 14:29:15
【问题描述】:

我已经解决这个问题好几天了,没有变得更聪明。

在 main.xml 中,我收到一条错误消息: "布局文件中引用的类,com.google.android.maps.MapView, 在项目或库中找不到”

这真的让我很困惑,因为我在 Google API [Android 2.3.3] 中看到了 MapView.class 地图.jar

有解决此问题的想法吗?这真的让我很烦我找不到 我自己的解决方案。

我的 API 密钥是 Ver。 2

我正在使用 Eclipse - Android 开发者工具版本:v22.0.0-675183

main.xml

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

<com.google.android.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:enabled="true"
    android:clickable="true"
    android:apiKey="AIzaSyCSeU48SfPfRRuA-3YycsVxd_s9MFV8g3M"
    />
</LinearLayout>

还有清单

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

<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />

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

<permission
android:name="com.tit.GPSLocator.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission  android:name="com.tit.GPSLocator.permission.MAPS_RECEIVE" />
<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" />    
<uses-permission android:name="android.permission.INTERNET" />

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

    <uses-library android:name="com.google.android.maps" />
    <activity android:name="com.tit.GPSLocator.GPSLocatorActivity"
            android:label="@string/app_name">
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyCSeU48SfPfRRuA-3YycsVxd_s9MFV8g3M" />

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

</application>
</manifest>

【问题讨论】:

  • 你试过清理项目吗?
  • 哦,是的。好几次。无论如何谢谢:)
  • 好的,在中移动API密钥之后,我再次清理了项目,我可以运行应用程序了。我在地图上得到了网格,但没有地图瓷砖:“java.io.IOException:服务器返回:3”但这是一个不同的问题。

标签: android eclipse google-maps


【解决方案1】:

您很可能一开始就不应该使用com.google.android.maps.MapView。这适用于已弃用的 Maps V1 API。你正在做的所有其他事情——特别是你的 API 密钥——来自the Maps V2 API

【讨论】:

  • 是的,我看到一些关于 MapView 被弃用的信息,但后来我发现:link 并且没有提到弃用。无论如何,我认为这与 API 版本无关,因为我在 Google API [Android 2.3.3] maps.jar 中看到了 MapView.class,所以它就在那里。
  • @MogensBurapa:“是的,我看到一些关于 MapView 被弃用的信息,但后来我发现:链接并且没有提到弃用”——这不是你正在使用的类。该页面适用于 Maps V2 MapView,即 com.google.android.gms.maps.MapView。你没有使用那个。您正在使用 com.google.android.maps.MapView,即 Maps V1 MapView。请勿将 Maps V1 与 Maps V2 混合搭配使用。
  • 但还是这样。 MapView.class 在那里,应该被 Eclipse 识别。
【解决方案2】:

好的,在将meta-data API key 移动到activity 之后,我再次清理了项目,我可以运行应用程序了。我在地图上找到了网格,但没有地图块:java.io.IOException: Server returned: 3,但这是一个不同的问题。

【讨论】:

    猜你喜欢
    • 2021-08-25
    • 1970-01-01
    • 2017-02-09
    • 2015-08-25
    • 1970-01-01
    • 2021-03-26
    • 2019-06-30
    • 2019-07-08
    • 2016-11-22
    相关资源
    最近更新 更多