今天看了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> <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"/>
<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> <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><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/