将 Google API 添加到现有的 eclipse 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13660758/
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
Add Google API to existing eclipse project
提问by Mario Dennis
I am writing an android app that will use Google Maps but to implement this I need the Google API. When I downloaded the android platform sdk (example android 4.0) I did not download the Google API cause did not know that I would need it to implement this feature.However, I went back and downloaded it. How do I add it to my existing project. Did some searching and all showed how to start a new project with the API but not how to add it to the existing project.
我正在编写一个将使用 Google 地图的 android 应用程序,但要实现这一点,我需要 Google API。当我下载 android 平台 sdk(例如 android 4.0)时,我没有下载 Google API,因为我不知道我需要它来实现这个功能。但是,我回去下载了它。如何将它添加到我现有的项目中。做了一些搜索,所有内容都展示了如何使用 API 启动一个新项目,但没有展示如何将其添加到现有项目中。
回答by Joel Dean
Since you have already downloaded the Google APIs for the version that you are developing for, example Android 4. all you have to do is:
由于您已经为您正在开发的版本(例如 Android 4)下载了 Google API。您所要做的就是:
Right click on your project -> Go to Properties -> Then Android - > Then select the Google APIs at API level 14
Right click on your project -> Go to Properties -> Then Android - > Then select the Google APIs at API level 14
回答by noobcoder
Try this simple thing. In your file which you need the google maps api which extends 'Activity', replace Activity with MapActivity. It should have a red line showing error on your code. hover mouse over it and click on the option 'Fix Project Setup'. you will then find an option that suggests you to import Google APIs. select it, and you are done. Let me know if that works.
试试这个简单的东西。在您需要扩展“Activity”的 google maps api 的文件中,将 Activity 替换为 MapActivity。它应该有一条红线显示您的代码错误。将鼠标悬停在它上面,然后单击“修复项目设置”选项。然后您会找到一个建议您导入 Google API 的选项。选择它,你就完成了。让我知道这是否有效。