我怎样才能建立在Android的Studio中使用谷歌地图API第2版Android应用程序? [英] How can I create an Android application in Android Studio that uses the Google Maps Api v2?

查看:620
本文介绍了我怎样才能建立在Android的Studio中使用谷歌地图API第2版Android应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直有很多的麻烦,在Android的工作室试图建立与GoogleMap的一个应用程序。

I've been having lots of trouble in Android Studio trying to create an app with GoogleMap.

我按照以下指南:

<一个href="https://developers.google.com/maps/documentation/android/start">https://developers.google.com/maps/documentation/android/start

在与(几乎)使用Eclipse作为我的IDE没有问题。以前我从来没有使用过的IntelliJ,从偏食我遇到困难,整个项目/模块的范例来了。

before with (almost) no issues using eclipse as my IDE. I have never used intellij before, and coming from eclipse i'm having difficulty with the whole project/module paradigm.

我一直没能成功配置了谷歌播放服务SDK <一href="http://developer.android.com/google/play-services/setup.html">http://developer.android.com/google/play-services/setup.html

I haven't been able to successfully configure the google play services sdk http://developer.android.com/google/play-services/setup.html

下面是奇怪的错误,我得到一个:

Here is one of the weird errors I'm getting:

Gradle: 
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':MyMapApp:compileDebug'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

任何帮助将是很大的AP preciated。

Any help would be greatly appreciated.

推荐答案

最后,我设法采用Android Studio运行GoogleMapsAPIv2项目。

Finally I managed to run GoogleMapsAPIv2 project using Android Studio.

编辑:正如由Xavier,这种方法是去工作的唯一的非摇篮基础的项目。和UI部分这是在本教程中使用的将被排除AndroidStudio。所以,如果你有自己的项目,该项目采用摇篮构建系统,您需要手动修改build.gradle配置文件,因为Android的工作室UI不会对其产生影响。

EDIT2:随着AndroidStudio v0.1.1版本中,负责模块的依赖UI部分已经被淘汰,所以现在我们需要手动通过build.gradle文件更新的依赖关系。 UI改变摇篮的依赖将是在发布下一个版本

EDIT3:对于那些谁仍然试图用这个办法 - 请注意,这是过时的,不工作了

下面是我做的:

1)我把地图项目中发挥服务样本和复制,要在不同的目录。这将是我们的MapsApiV2项目,我们将试图运行。在我的Mac它位于&LT; sdk_location&GT; /演员/谷歌/ google_play_services /样本 我把它给〜/工作/堆栈/

1) I took maps project from the Google Play Services samples and copied that to the separate directory. That is going to be our MapsApiV2 project we will be trying to run. On my Mac it was located at <sdk_location>/extras/google/google_play_services/samples I placed it to the ~/Work/stack/

2)复制谷歌播放services_lib 项目目录到同一个地方(〜/工作/堆栈) ,所以我的工作目录看起来是这样的。顺便说一句,LIB项目位于&LT; sdk_location&GT; /演员/谷歌/ google_play_services / libproject

2) Copied google-play-services_lib project directory to the same place (~/Work/stack), so my working directory looks like this. Btw, lib project is located at <sdk_location>/extras/google/google_play_services/libproject:

3)现在,让我们打开Android的工作室。在欢迎屏幕preSS 导入项目和进口我们的地图〜/工作项目/堆栈/图。现在我们看到了很多关于未知参考GMS库投诉:

3) Now let's open Android Studio. On welcome screen press Import Project and import our maps project from ~/Work/stack/maps. Now we see a lot of complaints about unknown reference to GMS library:

4)现在,我们需要添加谷歌Play业务作为一个参考图书馆。将查看 - &GT;打开模块设置

4) Now we need to add Google Play Service as a reference library. Going to View -> Open Module Settings

5)在模块选项卡,单击 + 按钮,然后选择导入模块并导入GooglePlayServices库。我没有在奇才改变什么,所以点击下一页一路结束:

5) On the Modules tab, click + button and select Import Module and import your GooglePlayServices lib. I didn't change anything in the wizards, so clicked Next all the way to the end:

6)现在,您需要引用该进口的库。再次打开该屏幕(请参阅查看 - &GT;模块设置)。请确保你有你的地图项目依赖选项卡中选择。点击 + 来添加一个依赖,选择。选择你的导入库有:

6) Now you need to reference this imported library. Open this screen again (go to View -> Module Settings). Make sure you have your maps project and Dependency tab selected. Click + to add a dependency and select Library. Choose your imported library there:

7)现在我们可以看到,它是不是在抱怨 GMS 库,但仍抱怨支持库:

7) Now we can see that it is not complaining about GMS library, but still complaining about support library:

8)让我们来解决它。我有我的支持库位于&LT; SDK地点&gt; /extras/android/support/v13/android-support-v13.jar 。所以,让我们试着将它添加到我们的工作区。转到查看 - &GT;打开模块设置,然后选择设置页。选择 + - > 的Java ,并选择支持库:

8) Let's fix it. I have my support library located at <sdk location>/extras/android/support/v13/android-support-v13.jar. So let's try to add it to our workspace. Go to View -> Open Module Settings and select Libraries tab. Select + -> Java and select support library:

9)现在人们要问你要添加的项目这个lib加入,所以一定要确保你选择了你地图的项目:

9) Now it is going to ask you which project to add this lib to, so make sure you have selected your maps project:

10)在这一点上code应该编译W / O问题。只要确保你的目标正确的SDK版本的清单。

10) At this point code should compile w/o problems. Just make sure you are targeting the right SDK version in Manifest.

玩得开心

这篇关于我怎样才能建立在Android的Studio中使用谷歌地图API第2版Android应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆