java 无法解析/无法解析为类型
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16207377/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot be resolved / Cannot be resolved to a type
提问by Teo Chuen Wei Bryan
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.
我收到了无法解析为类型的错误。我是 Java 的初学者,我正在尝试开发一个 android 应用程序。我在收到无法解决类型错误的地方放了一个推荐标志。
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)));
}
}
回答by Emil Adz
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:
如果您在MapFragment
and上遇到错误Marker
,那么您引用google-play-services
库的方式存在一些问题。看看我写的这篇博文,前 3 个步骤将向你解释如何正确地做到这一点:
回答by RQube
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.
如果您在 Eclipse 中引用 google-play-service 时遇到问题,请将 Google Play 服务库和您的项目放在同一个工作区中。它有效......并且不要忘记添加支持库。