简体   繁体   English

将Google Play服务库导入Android Studio 1.0

[英]Import Google Play Service library to Android studio 1.0

I'm trying to implement GCM in an Android project with Android Studio 1.0. 我正在尝试在使用Android Studio 1.0的Android项目中实现GCM。

I've installed Google Play Service library but I'm confused about ,how to import the one to project. 我已经安装了Google Play服务库,但对如何导入一个到项目中感到困惑。

Does anyone know how to do it? 有人知道怎么做吗?

Thanks in advance! 提前致谢!

Since you are using Android Studio, you are presumably also using Gradle. 由于您使用的是Android Studio,因此您大概也在使用Gradle。 If this is the case, then you do not need to worry about importing any projects. 如果是这种情况,那么您不必担心导入任何项目。

Simply open up the build.gradle in your app module, and locate the depencies {} closure. 只需在您的应用模块中打开build.gradle ,然后找到depencies {}闭合。

Inside of this section, add the Google Play Services dependency like so: 在此部分的内部,添加Google Play服务依赖项,如下所示:

dependencies {
    // ...

    compile 'com.google.android.gms:play-services:6.5.+'
}

Once you have done that, you can use any classes from Google Play Services anywhere in your application. 完成此操作后,您可以在应用程序中的任何位置使用Google Play服务中的任何类。

Be sure to read through the Setting up Google Play Services documentation , as you also need to include a <meta-data> element in your manifest, and you can also choose to selectively include only the parts of Google Play Services that you will be using. 请务必通读“ 设置Google Play服务”文档 ,因为您还需要在清单中包含<meta-data>元素,并且您还可以选择仅选择包含将要使用的Google Play服务部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM