2015-05-08 67 views
0

我以前一直在使用Google Play,但在一个新项目中遇到了一个奇怪的问题。我使用SDK Manager下载了GP,并通过Project Structure/Dependencies添加了它,它自动在build.gradle依赖项中添加了一行。 但是当我做重建项目,它失败:无法找到Google Play版本

Error:A problem occurred configuring project ':app'. 
> Could not resolve all dependencies for configuration ':app:_debugCompile'. 
    > Could not find any version that matches com.google.android.gms:play-services:+. 
Searched in the following locations: 
    https://jcenter.bintray.com/com/google/android/gms/play-services/maven-metadata.xml 
    https://jcenter.bintray.com/com/google/android/gms/play-services/ 
    https://repo1.maven.org/maven2/com/google/android/gms/play-services/maven-metadata.xml 
    https://repo1.maven.org/maven2/com/google/android/gms/play-services/ 
    http://jzaccone.github.io/SlidingMenu-aar/com/google/android/gms/play-services/maven-metadata.xml 
    http://jzaccone.github.io/SlidingMenu-aar/com/google/android/gms/play-services/ 
    https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/maven-metadata.xml 
    https://oss.sonatype.org/content/repositories/snapshots/com/google/android/gms/play-services/ 
    file:/Users/thatsme/android-sdks/extras/android/m2repository/com/google/android/gms/play-services/maven-metadata.xml 
    file:/Users/thatsme/android-sdks/extras/android/m2repository/com/google/android/gms/play-services/ 
    file:/Users/thatsme/android-sdks/extras/google/m2repository/com/google/android/gms/play-services/maven-metadata.xml 
    file:/Users/thatsme/android-sdks/extras/google/m2repository/com/google/android/gms/play-services/ 
Required by: 
    GA:app:unspecified 
+1

千万不要使用'com.google.android.gms:玩-services'直接。分别使用它们,最新版本为“7.3.0”。 –

+0

你是什么意思? – michaelsmith

+1

表示您可以加载模块化服务,并请通知版本。检查:http://developer.android.com/google/play-services/setup.html –

回答

0

添加此体现

<application> 
     ... 
    <meta-data 
     android:name="com.google.android.gms.version" 
     android:value="@integer/google_play_services_version" /> 
</application> 
+0

这就是我的 – michaelsmith

0

打开SDK管理器,检查是否有所有必需的包:

To develop with Google APIs, you need the Google Play services package: Open the Extras directory and select:

  • Google Repository
  • Google Play services

参考http://developer.android.com/sdk/installing/adding-packages.html

Then:

To make the Google Play services APIs available to your app:

  1. Open the build.gradle file inside your application module directory.

  2. Add a new build rule under dependencies for the latest version of play-services. For example:

    dependencies { 
        compile 'com.google.android.gms:play-services:7.3.0' 
    } 
    
  3. Save the changes and click Sync Project with Gradle Files in the toolbar.

参考:http://developer.android.com/google/play-services/setup.html#Setup

+0

当我这样做时,它说: 错误:无法找到com.google.android.gms:play -services:7.3.0。 需求: GA:app:未指定 – michaelsmith

+0

检查您是否也安装了“Google Repository”。否则,您还必须在SDK Manager中安装“Google Repository”。 –