将Google Play服务纳入Android Studio项目 [英] Including Google Play Services to Android Studio project

查看:178
本文介绍了将Google Play服务纳入Android Studio项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试将最新的Google Play服务库包含到我的Android Studio项目中,以便使用推送消息和Maps API.

I've been trying to include the latest Google Play Services library to my Android Studio project in order to use push messages and Maps API.

由于有很多关于如何在Eclipse和CLI上包含此库的教程 ,没有关于如何在Android Studio中包括最新库的说明.

Since there are plenty of tutorials on how to include this library on Eclipse and CLI , there are no instructions on how to include the latest library on Android Studio.

我一直在许多网站上搜索,看起来最合适的答案之一是这一个,因为其他版本似乎在记录较旧的版本,但仍然看起来像我遗漏了一些东西.

I've been searching on many sites and one of the answers which looked to be the most fitting looked to be this one, since other ones appear to document an older version, but it still appears like I'm missing something.

我试图以与将Facebook库包含到我的项目中一样的方式包含此库(奇怪的是,Android Studio的文档记录比GooglePlay更好),但看起来仍然缺少某些内容.

I've tried to include this lib the same way I included the Facebook library to my project (which is oddly better documented for Android Studio than GooglePlay is) but it still looks like i'm missing something.

为此,我将整个文件夹<android-sdk>\extras\google\google_play_services\libproject\google-play-services_lib复制到了我的<project-path>\libraries\google-play-services_lib

To do so, I've copied the whole folder <android-sdk>\extras\google\google_play_services\libproject\google-play-services_lib to my <project-path>\libraries\google-play-services_lib

然后在Studio中,我尝试在模块">添加">导入"模块中添加复制的文件夹,如Facebook文档或提供的链接中所述.我一定会忘记诸如gradle文件之类的东西,检查模块属性,我真的不知道我对该lib正在做什么.

Then in Studio, i tried to add the copied folder in Module > add > Import module, like said in the Facebook documentation or in the link provided. I must be forgetting something like a gradle file, checking a module property, i don't really know anymore what i'm doing with this lib.

我很想在Android Studio上工作.

I AM alreay working on Android Studio.

推荐答案

使用Android Studio,您唯一需要做的就是编辑build.gradle文件,并确保没有 android或google jar库,这意味着您需要从项目中删除jar库(除非您正在使用ActionbarSherlock之类的库,可能需要jar库).

Using Android Studio, the only thing you need is to edit the build.gradle file and make sure that there are no android or google jar libraries, which means that you will need to remove jar libraries from your project (unless you're using libs like ActionbarSherlock which may need jar libs).

如果您计划使用Google Play服务,则build.gradle文件应如下所示:

If you plan using Google Play Services, your build.gradle file should look like this :

dependencies {
    compile 'com.android.support:support-v4:13.0.+'
    compile 'com.android.support:support-v13:13.0.+'
    compile 'com.google.android.gms:play-services:3.1.36'
}

确实很简单

此外,如果您使用的是Facebook SDK,则需要根据主项目的build.gradle编辑其build.gradle文件并更改其依赖性.

Also, if you're using Facebook SDK, you will need to edit its build.gradle file and change its dependencies in accordance to your main project's build.gradle.

这篇关于将Google Play服务纳入Android Studio项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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