Cannot be resolved / Cannot be resolved to a type

守給你的承諾、 提交于 2021-02-04 21:15:48

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!