eclipse 导入 com.google 无法解析
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17110299/
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
The import com.google cannot be resolved
提问by Josh Boothe
I am trying to do a Map View in android (migrating from iOS). In the android SDK pannel I have google APIs (API 17) installed, which I was hoping would fix the problem. So in my source code I have:
我正在尝试在 android 中执行地图视图(从 iOS 迁移)。在 android SDK 面板中,我安装了 google API(API 17),我希望它可以解决问题。所以在我的源代码中,我有:
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
And its giving me the error: The import com.google cannot be resolved
. I have searched google for a result, but they havent worked (most of them were making sure the Google API is installed.
它给了我错误:The import com.google cannot be resolved
. 我已经在谷歌上搜索了结果,但他们没有工作(他们中的大多数人都确保安装了谷歌 API。
I am on a Macbook Pro, 64 bit using Eclipse ADT downloaded from the android dev site.
我在 64 位 Macbook Pro 上,使用从 android 开发站点下载的 Eclipse ADT。
In the AndroidManifest.xml
file I have:
在AndroidManifest.xml
文件中我有:
<uses-library android:name="com.google.android.maps" />
回答by Timothy T.
You have to add the library to your project.
您必须将库添加到您的项目中。
You can find the .jar file in your sdk
sdk\add-ons\addon-google_apis-google-17\libs\maps.jar
您可以在 sdk 中找到 .jar 文件
sdk\add-ons\addon-google_apis-google-17\libs\maps.jar
Thread about how to add a library in your android project : Adding a library/JAR to an Eclipse Android project
关于如何在您的 android 项目中添加库的主题: 将库/JAR 添加到 Eclipse Android 项目
回答by CommonsWare
You also need to set the build target (Project > Properties > Android) to be a build target that has the Google APIs in it, to use Maps V1.
您还需要将构建目标(项目 > 属性 > Android)设置为包含 Google API 的构建目标,以使用 Maps V1。
That being said, Raghunandan is correct -- you should be using Maps V2, as you can no longer get Maps V1 API keys. Note that Maps V2 does notrequire you to have a "Google APIs" build target.
话虽如此,Raghunandan 是正确的——您应该使用 Maps V2,因为您无法再获得 Maps V1 API 密钥。需要注意的是地图V2并没有要求你有一个“谷歌的API”构建目标。