2015-05-08 66 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」。 –