gpt4 book ai didi

java - android map 查看错误

转载 作者:行者123 更新时间:2023-12-01 15:22:17 25 4
gpt4 key购买 nike

我从example做同样的事情,但 Eclipse 返回错误。代码如下:

package hello.google.map;

import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;

public class MapsActivity extends MapActivity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}

@Override
protected boolean isRouteDisplayed() {
return false;
}
}

错误如下:

*

Description Resource    Path    Location    Type
MapActivity cannot be resolved to a type HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 7 Java Problem
MapActivity cannot be resolved to a type HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 13 Java Problem
The import com.google cannot be resolved HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 3 Java Problem
The import com.google cannot be resolved HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 4 Java Problem
The method isRouteDisplayed() of type MapsActivity must override a superclass method HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 18 Java Problem
The method onCreate(Bundle) of type MapsActivity must override a superclass method HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 11 Java Problem
The method setContentView(int) is undefined for the type MapsActivity HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 14 Java Problem
The public type MapsActivity must be defined in its own file HelloGoogleMapsActivity.java /HelloGoogleMaps/src/hello/google/map line 7 Java Problem*
为什么?我做错了什么?

最佳答案

从表面上看,您可能错过了两件事。要么您忘记将以下内容添加到 AndroidManifest.xml

<uses-library android:name="com.google.android.maps" />

或者,您尝试在具有普通 Android API(而不是特殊 Google API 版本)的模拟器上运行它。您需要此 Google API 版本才能使用 map 等功能。

如果您没有,不用担心,您可以在 SDK Manager 中下载。然后,只需创建一个新的 AVD 并将目标设置为目标 API 级别的 Google API 版本即可。

关于java - android map 查看错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10731574/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com