Today I have read the document of Google Maps Android API v2, it said the project of android-sdk\extras\google\google_play_services\samples\maps
can run,
but after I imported into eclipse and set the libraries of android-support-v4.jar
and google-play-services.jar correctly, import com.example.mapdemo.R;
in FeatureView.java
(at line 24) can not find the file R.java.
almost all the java file in com.example.mapdemo
need class "R", for example, the file BasicMapActivity.java need R in 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> <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 said "cameraTargetLat", "cameraTargetLng" and "cameraZoom" can not recognized. The 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> <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>
the errors disappeared, but i do not know if it can run.
Copy the maps_attr.xml file from the library project into your project's values folder.
You should also import google-play-services_lib project (/extras/google/google_play_services/libproject/google-play-services_lib) - after that cameraTargetLat and other ones are recognized and R.java is generated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With