The Google Maps Android API v2 com.example.mapdemo cannot find the file "R.java",

Today I read the Google Maps Android v2 API document, he said that the project android-sdk\extras\google\google_play_services\samples\mapscan start, but after I imported into eclipse and installed the libraries android-support-v4.jarand google-play-services.jar correctly, I cannot find the file import com.example.mapdemo.R;in FeatureView.java(line 24)R.java.

almost the entire java file in com.example.mapdemoneed a class "R", for example, the file BasicMapActivity.java needs R on line 41 " setContentView(R.layout.basic_demo);" and line 71 mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();"can someone tell me how to find the class" 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 said that "cameraTargetLat", "cameraTargetLng" and "cameraZoom" are not recognized. Error Information:

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>

, , .

+5
7

maps_attr.xml .

+8

google-play-services_lib (/extras/google/google_play_services/libproject/google-play-services_lib) - , CameraTargetLat R.java .

+1

/extras/google/google_play_services/libproject/google-play-services_lib .

  • /extras/google/google_play_services/libproject/google-play-services_lib, , WORKSPACE (, , )
  • → Android "google-play-services"
  • android-support-v4.jar google-play-services.jar JAR
0

1,
2, copy\extras\google\google_play_services\libproject\google-play-services_lib\res\values ​​\ maps_attrs.xml

3, google-play-services_lib .

: java.lang.NoClassDefFoundError: com.google.android.gms.R $styleable android

0

AndroidManifest.xml

 <meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
0

, - . , . Sample project of Map Google play service ,

, , . ,

0

xmlns:map="http://schemas.android.com/apk/res-auto" xml map.

The R file autogenerates by Eclipse, and you can find it in the directory gen. Do not edit this file ever! In some cases, you will find more than one R file there, for example, when you add a library to your project, for example google-play-services_lib. You can always link to this file with this code ...

mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(com.your.package.R.id.map)).getMap();

If you want to customize your map, it is possible to make its attributes XML or Programmatically .

-1
source

All Articles