2013-08-24 47 views
1

我已经在这个问题上好几天了,现在还没有明白。com.google.android.maps.MapView,在项目或库中找不到

main.xml中我得到一个错误说:

这真是“级的布局文件,com.google.android.maps.MapView引用, 没有在项目或库中找到”拼图我,因为我看到Google API中的MapView.class [Android 2.3.3] maps.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> 
+0

您是否尝试过清洁项目? – wakaka

+0

哦,是的。很多次。无论如何,谢谢:) –

+0

好吧,在中移动API密钥后,我再次清理了项目,并且我可以运行该应用程序。我在地图上获取网格,但没有映射图块:“java.io.IOException:服务器返回:3”,但这是另一个问题。 –

回答

0

最有可能的,你应该首先不要使用com.google.android.maps.MapView。这是针对已弃用的Maps V1 API。您正在做的其他事情 - 特别是您的API密钥 - 来自the Maps V2 API

+0

是的,我看到一些关于MapView被弃用,但后来我发现:[链接](https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapView ),并没有提及过时。无论如何,我不认为这与API版本有关,因为我在Google API [Android 2.3.3] maps.jar中看到了MapView.class,所以它就在那里。 –

+0

@MogensBurapa:“是的,我看到一些关于MapView被弃用,但后来我发现这个:链接,并没有提及弃用的” - 这不是你正在使用的类。该页面适用于Maps V2'MapView',它是'com.google.android.gms.maps.MapView'。你没有使用它。您正在使用'com.google.android.maps.MapView',它是Maps V1'MapView'。不要将Maps V1与Maps V2混合搭配。 – CommonsWare

+0

是的,你对上述链接是正确的。我的错。 –

0

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

相关问题