问题
I recevied error like cannot be resolved to a type. I'm a beginner at java and i'm attempting to develop an android application. I put a commend sign at the place where i received the cannot be resolved to a type error.
package com.example.majorproject;
import com.vogella.android.locationapi.maps.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MajorProject extends Activity {
static final //LatLng HAMBURG = new //LatLng(53.558, 9.927);
static final //LatLng KIEL = new //LatLng(53.551, 9.993);
private //GoogleMap map;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
if (//map!==null){
//Marker hamburg = map.addMarker(new //MarkerOptions().position(//HAMBURG)
.title("Hamburg"));
//Marker kiel = map.addMarker(new MarkerOptions()
.position(//KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(//BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
}
}
回答1:
If you are getting error on the MapFragment
and Marker
, then you have some problem with the way you are referencing the google-play-services
library. Take a look at this blog post I wrote, the 3 first steps will explain to you how to do it properly:
Google Maps API V2
回答2:
if you are having problem while referencing google-play-service in eclipse, then place the Google play service lib and your project in same workspace. It works.... and don't forget to add support library.
来源:https://stackoverflow.com/questions/16207377/cannot-be-resolved-cannot-be-resolved-to-a-type