google-maps-android-api-2 - Google Maps Android API v2 com.example.mapdemo 示例无法找到文件 "R.java"

标签 google-maps-android-api-2

今天看了Google Maps Android API v2的文档,里面说的是android-sdk\extras\google\google_play_services\samples\maps的项目。能跑,
但是在我导入 eclipse 并设置了 android-support-v4.jar 的库之后和 google-play-services.jar 正确,import com.example.mapdemo.R;FeatureView.java (在第 24 行)找不到文件 R.java.com.example.mapdemo中几乎所有的java文件需要类“R”,例如文件BasicMapActivity.java在第41行“setContentView(R.layout.basic_demo);”和第71行mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();中需要R ”
有人能告诉我如何找到“R”类吗?

电阻

.java can not create automatically because the file multimap_demo.xml have some errors in
<br><br>    &lt;fragment
<br>      android:id="@+id/map3"
<br>      android:layout_width="match_parent"
<br>      android:layout_height="match_parent"
<br>      android:layout_weight="0.5"
<br>      class="com.google.android.gms.maps.SupportMapFragment"
<br>      map:cameraTargetLat="48.85"
<br>      map:cameraTargetLng="2.35"
<br>      map:cameraZoom="8"/&gt;
<br><br>

eclipse 说无法识别“cameraTargetLat”、“cameraTargetLng”和“cameraZoom”。
错误信息:
Multiple annotations found at this line:
    - error: No resource identifier found for attribute 'cameraTargetLat' in package 'com.example.mapdemo'
    - error: No resource identifier found for attribute 'cameraTargetLng' in package 'com.example.mapdemo'
    - error: No resource identifier found for attribute 'cameraZoom' in package 'com.example.mapdemo'

I do not know why.

If I change the code like this:
<br><br>    &lt;fragment
<br>      android:id="@+id/map3"
<br>      android:layout_width="match_parent"
<br>      android:layout_height="match_parent"
<br>      android:layout_weight="0.5"
<br>      class="com.google.android.gms.maps.SupportMapFragment"/&gt;
<br><br>

错误消失了,但我不知道它是否可以运行。

最佳答案

将 maps_attr.xml 文件从库项目复制到项目的 values 文件夹中。

关于google-maps-android-api-2 - Google Maps Android API v2 com.example.mapdemo 示例无法找到文件 "R.java",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14503168/

相关文章:

android - 将两个 TextView 放在包含 Google map 的 fragment 上方

Android 谷歌地图最小缩放

android - 如何在android中找到距折线的距离?

android - 在 Google map 中,当应用程序从最小化状态最大化时,为什么不再调用 OnLocationChanged()?

Android Streetview - 避免室内位置

java - Android 谷歌地图 v2 启动时崩溃

java - 如何在谷歌地图android上显示多个标记

android - 将 GoogleMap 缩放到我的位置

java - 支持MapFragment和NullPointerException

java - 如何在Arraylist上正确添加Google Map上的添加标记