使用谷歌的Android Studio播放服务

时间:2021-04-15 15:22:22

I'm trying to test Google Play Services with the new Android Studio. I have a project with a dependency to the google_play_services.jar. But when I try to Rebuild the project I get the following errors:

我正在尝试用新的Android Studio测试谷歌播放服务。我有一个项目与google_play_services.jar有依赖关系。但是当我尝试重新构建项目时,我得到了以下错误:

Information:[TstGP3-TstGP3] Crunching PNG Files in source dir: C:\Users\ans\AndroidStudioProjects\TstGP3\TstGP3\src\main\res
Information:[TstGP3-TstGP3] To destination dir: C:\Users\ans\AndroidStudioProjects\TstGP3\build\classes\res-cache\TstGP3-TstGP3
Information:Compilation completed with 2 errors and 0 warnings in 2 sec
Information:2 errors
Information:0 warnings
C:\Users\ans\.AndroidStudioPreview\system\compiler\tstgp3.3f17bd41\.generated\Android_BuildConfig_Generator\TstGP3-TstGP3.74fc5b25\production\com\example\tstgp3\BuildConfig.java
    Error:Error:line (4)error: duplicate class: com.example.tstgp3.BuildConfig
C:\Users\ans\.AndroidStudioPreview\system\compiler\tstgp3.3f17bd41\.generated\aapt\TstGP3-TstGP3.74fc5b25\production\com\example\tstgp3\R.java
    Error:Error:line (10)error: duplicate class: com.example.tstgp3.R

It seems that it has two BuildConfig files and also two R classes. How can I resolve the issue?

它似乎有两个BuildConfig文件和两个R类。我如何解决这个问题?

EDIT:

编辑:

I have noticed that the compiler compiles two R.java files: the one that is in my project folder and another one that is located in the folder %USERPROFILE%.AndroidStudioPreview So, I tried to exclude this "Preview" folder in the compiler settings and now it's working. This issue only occurs after I have started to use Google Play Services classes in my project. I will appreciate if someone can explain the reason behind this problem.

我注意到编译器编译两个R。java文件:一个在我的项目文件夹中,另一个在文件夹%USERPROFILE%中。AndroidStudioPreview所以,我试着把这个“预览”文件夹排除在编译器设置中,现在它开始工作了。这个问题只发生在我开始在我的项目中使用谷歌游戏服务类之后。如果有人能解释一下这个问题的原因,我将不胜感激。

11 个解决方案

#1


244  

All those answers are wrong, since the release of gradle plugin v0.4.2 the setup of google play services under android studio is straight forward. You don't need to import any jar or add any project library nor add any new module under android studio. What you have to do is to add the correct dependencies into the build.gradle file. Please take a look to those links: Gradle plugin v0.4.2 update, New Build System, and this sample

所有这些答案都是错误的,因为gradle插件v0.4.2的发布,android studio下谷歌play服务的设置是直接的。您不需要导入任何jar或添加任何项目库,也不需要在android studio下添加任何新模块。您需要做的是将正确的依赖项添加到构建中。gradle文件。请查看这些链接:Gradle plugin v0.4.2更新、新构建系统和这个示例。

The Correct way to do so is as follows:

正确的做法如下:

First of all you have to launch the sdk manager and download and install the following files located under "extras": Android support repository, Google play services, Google repository.

首先,您需要启动sdk管理器并下载并安装以下文件,这些文件位于“extras”之下:Android support repository、谷歌play services、谷歌repository。

Restart android studio and open the build gradle file. You must modify your build.gradle file to look like this under dependencies:

重新启动android studio并打开构建级文件。您必须修改您的构建。在依赖项下的渐变文件如下:

dependencies {
    compile 'com.google.android.gms:play-services:6.5.87' 
 }

And finally syncronise your project (the button to the left of the AVD manager).

最后同步您的项目(AVD manager左边的按钮)。

Since version 6.5 you can include the complete library (very large) or just the modules that you need (Best Option). I.e if you only need Google Maps and Analytics you can replace the previous example with the following one:

由于版本6.5,您可以包含完整的库(非常大)或仅仅需要的模块(最佳选项)。我。e如果你只需要谷歌地图和分析,你可以用下面的例子代替之前的例子:

dependencies {  
    compile 'com.google.android.gms:play-services-base:6.5.87'    
    compile 'com.google.android.gms:play-services-maps:6.5.87'  
}

You can find the complete dependency list here

您可以在这里找到完整的依赖项列表

Some side notes:

一些笔记:

  • Use the latest play services library version. If it's an old version, android studio will highlight it. As of today (February 5th is 6.5.87) but you can check the latest version at Gradle Please
  • 使用最新的游戏服务库版本。如果是旧版本,android studio会高亮显示。从今天(2月5日是6.5.87)开始,您可以在第一次课上查看最新版本
  • After a major update of Android Studio, clean an rebuild your project by following the next instructions as suggested in the comments by @user123321

    在对Android Studio进行重大更新之后,按照@user123321的评论中建议的下一个指令来清理重新构建项目

    cd to your project folder
    ./gradlew clean
    ./gradlew build

    cd到你的项目文件夹。/清理等级。/建立等级

#2


111  

  1. Go to File -> Project Structure
  2. 转到File ->项目结构
  3. Select 'Project Settings'
  4. 选择“项目设置”
  5. Select 'Dependencies' Tab
  6. 选择“依赖性”选项卡
  7. Click '+' and select '1.Library Dependencies'
  8. 点击“+”,选择“1”。库依赖关系的
  9. Search for : com.google.android.gms:play-services
  10. 搜索:com.google.android.gms:游戏服务
  11. Select the latest version and click 'OK'
  12. 选择最新版本,点击“确定”

Voila! No need to fight with Gradle :)

瞧!没有必要和葛拉蒂打架:)

#3


5  

EDITED: This guy really brought it home and has a good little tutorial http://instantiatorgratification.blogspot.com/2013/05/google-play-services-with-android-studio.html

编辑:这个家伙真的把它带回家了,并且有一个很好的教程http://instantiatorgratific.blogspot.com/2013/05/google -play-services-with-android-studio.html

one side note: I had played around so much that I needed to do a gradlew clean to get it to run succesfully

有一点需要注意的是:我玩了太多的游戏,所以我需要做一个等级清理来让它顺利运行

If you have imported your project or are working from the Sample Maps application located in \extras\google\google_play_services\samples\maps check out this tutorial.

如果您已经导入了您的项目,或者正在从示例地图应用程序中进行工作,那么您可以在本教程中查看该应用程序。

https://*.com/a/16598478/2414698

https://*.com/a/16598478/2414698

If you are creating a new project from scratch then note Xav's comments on that same post. He describes that Android Studio uses a different compiler and that you have to modify the build.gradle file manually. I did this with success. I copied

如果您正在从头开始创建一个新项目,那么请注意Xav对同一篇文章的评论。他描述Android Studio使用不同的编译器,您必须修改构建。手动gradle文件。我成功地做到了这一点。我复制

  • google-play-services.jar
  • google-play-services.jar
  • google-play-services.jar.properties
  • google-play-services.jar.properties

into my lib directory and added the following to my build.gradle file

进入我的lib目录,并在我的构建中添加了以下内容。gradle文件

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('libs/google-play-services.jar')
}

Also, if this is a new project check out this post, too.

另外,如果这是一个新的项目,也看看这篇文章。

https://*.com/a/16671865/2414698

https://*.com/a/16671865/2414698

#4


4  

Most of these answers only address compile-time dependencies, but you'll find a host of NoClassDef exceptions at runtime. That's because you need more than the google-play-services.jar. It references resources that are part of the library project, and those are not included correctly if you only have the jar.

这些答案中的大多数只涉及编译时依赖项,但是您将在运行时发现大量的NoClassDef异常。那是因为你需要的不仅仅是google play .jar。它引用作为库项目一部分的资源,如果您只有jar,那么这些资源不会被正确地包含进来。

What worked best for me was to first get the project setup correctly in eclipse. Have your project structured so that it includes both your app and the library, as described here: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Multi-project-setup

对我来说,最有效的方法是首先在eclipse中正确地设置项目。让你的项目结构包括你的应用程序和库,如这里描述的:http://tools.android.com/tech- docs/新建-系统/用户指南#TOC-Multi-project-setup

Then export your app project from eclipse, and import into Android Studio as described here: http://developer.android.com/sdk/installing/migrate.html. Make sure to export both your app project and the google play services library project. When importing it will detect the library project and import it as a module. I just accepted all defaults during the project import process.

然后从eclipse导出应用程序项目,并导入Android Studio,如此处所述:http://developer.android.com/sdk/installing/migrate.html。确保导出您的应用程序项目和谷歌播放服务库项目。导入时将检测库项目并将其导入模块。我刚刚接受了项目导入过程中的所有默认值。

#5


2  

Google Play services Integration in Android studio.

谷歌在Android studio中运行服务集成。

Step 1:

步骤1:

SDK manager->Tools Update this

1.Google play services
2.Android Support Repository

Step 2:

步骤2:

chance in build.gradle 
defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:4.0.+'
}

Step 3:

步骤3:

 android.manifest.xml
<uses-sdk
        android:minSdkVersion="8" />

Step 4:

步骤4:

Sync project file with grandle.
wait for few minute.

Step 5:

步骤5:

File->Project Structure find error with red bulb images,click on go to add dependencies select your app module.
Save

Please put comment if you have require help. Happy coding.

如果您需要帮助,请提出意见。快乐的编码。

#6


2  

None of the above solution worked for me. Not sure if it is specific to my setup or new release.

以上的解决方案对我都不起作用。不确定是针对我的设置还是新版本。

I am using Android Studio Beta 0.8.9 and I was not getting any com.google.android.gms:play-service in the library list on following this instruction:

我使用的是Android Studio 0.8.9,没有任何com.google.android。gms:图书馆列表中的播放服务:

Go to File -> Project Structure -> Select Project Settings -> Select 'Dependencies' Tab Click '+' -> 1.Library Dependencies -> Select com.google.android.gms:play-services:+

进入文件->项目结构->选择项目设置->选择'Dependencies' Tab点击'+' -> 1。库依赖项->选择com.google.android.gms:play-services:+。

I had already done this:

我已经这样做了:

First of all you have to launch the sdk manager and download and install the following files located under "extras": Android support repository, Google play services, Google repository.

首先,您需要启动sdk管理器并下载并安装以下文件,这些文件位于“extras”之下:Android support repository、谷歌play services、谷歌repository。

What resolved it was to add from SDK Manager, "Google play services for Froyo" then repeating the first step.

解决了这个问题的是SDK管理器,“谷歌为Froyo提供服务”,然后重复第一步。

Did not understand the reason properly but this worked.

没有正确地理解原因,但这奏效了。

PS: I just observed that even now when I search for play-services this does not come, but when I directly scroll and look through the list it is right there.

PS:我刚刚发现,即使是现在,当我搜索播放服务时,它也不会出现,但当我直接滚动并查看列表时,它就在那里。

#7


2  

Follow this article -> http://developer.android.com/google/play-services/setup.html

遵循本文-> http://developer.android.com/google/play-services/setup.html。

You should to choose Using Android Studio

您应该选择使用Android Studio

使用谷歌的Android Studio播放服务

Example Gradle file:

Gradle文件示例:

Note: Open the build.gradle file inside your application module directory.

注意:打开构建。应用程序模块目录中的渐变文件。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "{applicationId}"
        minSdkVersion 14
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.google.android.gms:play-services:6.1.+'
}

You can find latest version of Google Play Services here: https://developer.android.com/google/play-services/index.html

您可以在这里找到谷歌最新版本的播放服务:https://developer.android.com/google/play-services/index.html

#8


1  

I've got this working after doing the following:

在做了以下工作后,我得到了这个工作:

  • Have the google-play-services-lib as a module (note difference between module and project), then add the google-play-services.jar to your models "libs" directory.
  • 将google-play-services-lib作为模块(注意模块和项目之间的差异),然后添加google-play-services。jar到您的模型“libs”目录。
  • After that add the jar to your build path through making a library or add the jar to another library. I generally have a single IDEA library which I add all my /libs/*.jar files to.
  • 然后通过创建一个库或将jar添加到另一个库,将jar添加到构建路径中。我通常只有一个想法库,我把我所有的/libs/*都加进去。jar文件。
  • Add the library to your modules build path through Module Settings (F4).
  • 通过模块设置(F4)将库添加到模块构建路径。
  • Add the google-play-services-lib as a module dependency to your project.
  • 将google-play-services-lib作为模块依赖项添加到项目中。
  • Done!
  • 完成了!

Note: This doesn't give me the runtime exceptions either, it works.

注意:这也没有给我运行时异常,它是有效的。

#9


0  

Open your project build.gradle file and add below line under dependencies module.

打开你的项目构建。gradle文件,并在依赖项模块下添加下一行。

dependencies {
    compile 'com.google.android.gms:play-services:7.0.0'
}

The below will be add Google Analytics and Maps if you don't want to integrate full library

如果您不想集成完整的库,下面将添加谷歌分析和映射

dependencies {
    compile 'com.google.android.gms:play-services-analytics:7.0.0'
    compile 'com.google.android.gms:play-services-maps:7.0.0'
}

#10


0  

In my case google-play-services_lib are integrate as module (External Libs) for Google map & GCM in my project.

在我的例子中,Google -play-services_lib作为模块(外部Libs)集成在我的项目中,用于谷歌map和GCM。

Now, these time require to implement Google Places Autocomplete API but problem is that's code are new and my libs are old so some class not found:

现在,这些时间需要实现谷歌Places自动完成API,但问题是代码是新的,我的libs是旧的,所以有些类没有找到:

following these steps...

以下步骤……

1> Update Google play service into SDK Manager

1>更新谷歌播放服务到SDK管理器

2> select new .jar file of google play service (Sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs) replace with old one

>选择new .jar文件的谷歌游戏服务(Sdk/extras/谷歌/google_play_services/libproject/google- services_lib/libs)替换旧的。

i got success...!!!

我成功了…! ! !

#11


-3  

I copied the play libs files from the google-play-services_lib to my project libs directory:

我将play libs文件从google-play-services_lib复制到我的项目libs目录:

  • google-play-services.jar
  • google-play-services.jar
  • google-play-services.jar.properties.
  • google-play-services.jar.properties。

Then selected them, right-click, "Add as libraries".

然后选择它们,右键单击“添加为库”。

#1


244  

All those answers are wrong, since the release of gradle plugin v0.4.2 the setup of google play services under android studio is straight forward. You don't need to import any jar or add any project library nor add any new module under android studio. What you have to do is to add the correct dependencies into the build.gradle file. Please take a look to those links: Gradle plugin v0.4.2 update, New Build System, and this sample

所有这些答案都是错误的,因为gradle插件v0.4.2的发布,android studio下谷歌play服务的设置是直接的。您不需要导入任何jar或添加任何项目库,也不需要在android studio下添加任何新模块。您需要做的是将正确的依赖项添加到构建中。gradle文件。请查看这些链接:Gradle plugin v0.4.2更新、新构建系统和这个示例。

The Correct way to do so is as follows:

正确的做法如下:

First of all you have to launch the sdk manager and download and install the following files located under "extras": Android support repository, Google play services, Google repository.

首先,您需要启动sdk管理器并下载并安装以下文件,这些文件位于“extras”之下:Android support repository、谷歌play services、谷歌repository。

Restart android studio and open the build gradle file. You must modify your build.gradle file to look like this under dependencies:

重新启动android studio并打开构建级文件。您必须修改您的构建。在依赖项下的渐变文件如下:

dependencies {
    compile 'com.google.android.gms:play-services:6.5.87' 
 }

And finally syncronise your project (the button to the left of the AVD manager).

最后同步您的项目(AVD manager左边的按钮)。

Since version 6.5 you can include the complete library (very large) or just the modules that you need (Best Option). I.e if you only need Google Maps and Analytics you can replace the previous example with the following one:

由于版本6.5,您可以包含完整的库(非常大)或仅仅需要的模块(最佳选项)。我。e如果你只需要谷歌地图和分析,你可以用下面的例子代替之前的例子:

dependencies {  
    compile 'com.google.android.gms:play-services-base:6.5.87'    
    compile 'com.google.android.gms:play-services-maps:6.5.87'  
}

You can find the complete dependency list here

您可以在这里找到完整的依赖项列表

Some side notes:

一些笔记:

  • Use the latest play services library version. If it's an old version, android studio will highlight it. As of today (February 5th is 6.5.87) but you can check the latest version at Gradle Please
  • 使用最新的游戏服务库版本。如果是旧版本,android studio会高亮显示。从今天(2月5日是6.5.87)开始,您可以在第一次课上查看最新版本
  • After a major update of Android Studio, clean an rebuild your project by following the next instructions as suggested in the comments by @user123321

    在对Android Studio进行重大更新之后,按照@user123321的评论中建议的下一个指令来清理重新构建项目

    cd to your project folder
    ./gradlew clean
    ./gradlew build

    cd到你的项目文件夹。/清理等级。/建立等级

#2


111  

  1. Go to File -> Project Structure
  2. 转到File ->项目结构
  3. Select 'Project Settings'
  4. 选择“项目设置”
  5. Select 'Dependencies' Tab
  6. 选择“依赖性”选项卡
  7. Click '+' and select '1.Library Dependencies'
  8. 点击“+”,选择“1”。库依赖关系的
  9. Search for : com.google.android.gms:play-services
  10. 搜索:com.google.android.gms:游戏服务
  11. Select the latest version and click 'OK'
  12. 选择最新版本,点击“确定”

Voila! No need to fight with Gradle :)

瞧!没有必要和葛拉蒂打架:)

#3


5  

EDITED: This guy really brought it home and has a good little tutorial http://instantiatorgratification.blogspot.com/2013/05/google-play-services-with-android-studio.html

编辑:这个家伙真的把它带回家了,并且有一个很好的教程http://instantiatorgratific.blogspot.com/2013/05/google -play-services-with-android-studio.html

one side note: I had played around so much that I needed to do a gradlew clean to get it to run succesfully

有一点需要注意的是:我玩了太多的游戏,所以我需要做一个等级清理来让它顺利运行

If you have imported your project or are working from the Sample Maps application located in \extras\google\google_play_services\samples\maps check out this tutorial.

如果您已经导入了您的项目,或者正在从示例地图应用程序中进行工作,那么您可以在本教程中查看该应用程序。

https://*.com/a/16598478/2414698

https://*.com/a/16598478/2414698

If you are creating a new project from scratch then note Xav's comments on that same post. He describes that Android Studio uses a different compiler and that you have to modify the build.gradle file manually. I did this with success. I copied

如果您正在从头开始创建一个新项目,那么请注意Xav对同一篇文章的评论。他描述Android Studio使用不同的编译器,您必须修改构建。手动gradle文件。我成功地做到了这一点。我复制

  • google-play-services.jar
  • google-play-services.jar
  • google-play-services.jar.properties
  • google-play-services.jar.properties

into my lib directory and added the following to my build.gradle file

进入我的lib目录,并在我的构建中添加了以下内容。gradle文件

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('libs/google-play-services.jar')
}

Also, if this is a new project check out this post, too.

另外,如果这是一个新的项目,也看看这篇文章。

https://*.com/a/16671865/2414698

https://*.com/a/16671865/2414698

#4


4  

Most of these answers only address compile-time dependencies, but you'll find a host of NoClassDef exceptions at runtime. That's because you need more than the google-play-services.jar. It references resources that are part of the library project, and those are not included correctly if you only have the jar.

这些答案中的大多数只涉及编译时依赖项,但是您将在运行时发现大量的NoClassDef异常。那是因为你需要的不仅仅是google play .jar。它引用作为库项目一部分的资源,如果您只有jar,那么这些资源不会被正确地包含进来。

What worked best for me was to first get the project setup correctly in eclipse. Have your project structured so that it includes both your app and the library, as described here: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Multi-project-setup

对我来说,最有效的方法是首先在eclipse中正确地设置项目。让你的项目结构包括你的应用程序和库,如这里描述的:http://tools.android.com/tech- docs/新建-系统/用户指南#TOC-Multi-project-setup

Then export your app project from eclipse, and import into Android Studio as described here: http://developer.android.com/sdk/installing/migrate.html. Make sure to export both your app project and the google play services library project. When importing it will detect the library project and import it as a module. I just accepted all defaults during the project import process.

然后从eclipse导出应用程序项目,并导入Android Studio,如此处所述:http://developer.android.com/sdk/installing/migrate.html。确保导出您的应用程序项目和谷歌播放服务库项目。导入时将检测库项目并将其导入模块。我刚刚接受了项目导入过程中的所有默认值。

#5


2  

Google Play services Integration in Android studio.

谷歌在Android studio中运行服务集成。

Step 1:

步骤1:

SDK manager->Tools Update this

1.Google play services
2.Android Support Repository

Step 2:

步骤2:

chance in build.gradle 
defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:4.0.+'
}

Step 3:

步骤3:

 android.manifest.xml
<uses-sdk
        android:minSdkVersion="8" />

Step 4:

步骤4:

Sync project file with grandle.
wait for few minute.

Step 5:

步骤5:

File->Project Structure find error with red bulb images,click on go to add dependencies select your app module.
Save

Please put comment if you have require help. Happy coding.

如果您需要帮助,请提出意见。快乐的编码。

#6


2  

None of the above solution worked for me. Not sure if it is specific to my setup or new release.

以上的解决方案对我都不起作用。不确定是针对我的设置还是新版本。

I am using Android Studio Beta 0.8.9 and I was not getting any com.google.android.gms:play-service in the library list on following this instruction:

我使用的是Android Studio 0.8.9,没有任何com.google.android。gms:图书馆列表中的播放服务:

Go to File -> Project Structure -> Select Project Settings -> Select 'Dependencies' Tab Click '+' -> 1.Library Dependencies -> Select com.google.android.gms:play-services:+

进入文件->项目结构->选择项目设置->选择'Dependencies' Tab点击'+' -> 1。库依赖项->选择com.google.android.gms:play-services:+。

I had already done this:

我已经这样做了:

First of all you have to launch the sdk manager and download and install the following files located under "extras": Android support repository, Google play services, Google repository.

首先,您需要启动sdk管理器并下载并安装以下文件,这些文件位于“extras”之下:Android support repository、谷歌play services、谷歌repository。

What resolved it was to add from SDK Manager, "Google play services for Froyo" then repeating the first step.

解决了这个问题的是SDK管理器,“谷歌为Froyo提供服务”,然后重复第一步。

Did not understand the reason properly but this worked.

没有正确地理解原因,但这奏效了。

PS: I just observed that even now when I search for play-services this does not come, but when I directly scroll and look through the list it is right there.

PS:我刚刚发现,即使是现在,当我搜索播放服务时,它也不会出现,但当我直接滚动并查看列表时,它就在那里。

#7


2  

Follow this article -> http://developer.android.com/google/play-services/setup.html

遵循本文-> http://developer.android.com/google/play-services/setup.html。

You should to choose Using Android Studio

您应该选择使用Android Studio

使用谷歌的Android Studio播放服务

Example Gradle file:

Gradle文件示例:

Note: Open the build.gradle file inside your application module directory.

注意:打开构建。应用程序模块目录中的渐变文件。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 20
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "{applicationId}"
        minSdkVersion 14
        targetSdkVersion 20
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.google.android.gms:play-services:6.1.+'
}

You can find latest version of Google Play Services here: https://developer.android.com/google/play-services/index.html

您可以在这里找到谷歌最新版本的播放服务:https://developer.android.com/google/play-services/index.html

#8


1  

I've got this working after doing the following:

在做了以下工作后,我得到了这个工作:

  • Have the google-play-services-lib as a module (note difference between module and project), then add the google-play-services.jar to your models "libs" directory.
  • 将google-play-services-lib作为模块(注意模块和项目之间的差异),然后添加google-play-services。jar到您的模型“libs”目录。
  • After that add the jar to your build path through making a library or add the jar to another library. I generally have a single IDEA library which I add all my /libs/*.jar files to.
  • 然后通过创建一个库或将jar添加到另一个库,将jar添加到构建路径中。我通常只有一个想法库,我把我所有的/libs/*都加进去。jar文件。
  • Add the library to your modules build path through Module Settings (F4).
  • 通过模块设置(F4)将库添加到模块构建路径。
  • Add the google-play-services-lib as a module dependency to your project.
  • 将google-play-services-lib作为模块依赖项添加到项目中。
  • Done!
  • 完成了!

Note: This doesn't give me the runtime exceptions either, it works.

注意:这也没有给我运行时异常,它是有效的。

#9


0  

Open your project build.gradle file and add below line under dependencies module.

打开你的项目构建。gradle文件,并在依赖项模块下添加下一行。

dependencies {
    compile 'com.google.android.gms:play-services:7.0.0'
}

The below will be add Google Analytics and Maps if you don't want to integrate full library

如果您不想集成完整的库,下面将添加谷歌分析和映射

dependencies {
    compile 'com.google.android.gms:play-services-analytics:7.0.0'
    compile 'com.google.android.gms:play-services-maps:7.0.0'
}

#10


0  

In my case google-play-services_lib are integrate as module (External Libs) for Google map & GCM in my project.

在我的例子中,Google -play-services_lib作为模块(外部Libs)集成在我的项目中,用于谷歌map和GCM。

Now, these time require to implement Google Places Autocomplete API but problem is that's code are new and my libs are old so some class not found:

现在,这些时间需要实现谷歌Places自动完成API,但问题是代码是新的,我的libs是旧的,所以有些类没有找到:

following these steps...

以下步骤……

1> Update Google play service into SDK Manager

1>更新谷歌播放服务到SDK管理器

2> select new .jar file of google play service (Sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs) replace with old one

>选择new .jar文件的谷歌游戏服务(Sdk/extras/谷歌/google_play_services/libproject/google- services_lib/libs)替换旧的。

i got success...!!!

我成功了…! ! !

#11


-3  

I copied the play libs files from the google-play-services_lib to my project libs directory:

我将play libs文件从google-play-services_lib复制到我的项目libs目录:

  • google-play-services.jar
  • google-play-services.jar
  • google-play-services.jar.properties.
  • google-play-services.jar.properties。

Then selected them, right-click, "Add as libraries".

然后选择它们,右键单击“添加为库”。