2016-05-31 157 views
1

我正在嘗試使用谷歌播放服務進行定位。因此我想將Google Play服務添加到我的應用程序中。在build.gradle依賴關係中,我添加了以下行。如何在Android Studio中查找google play服務版本?

compile 'com.google.android.gms:play-services:9.0.1' 

但是它提供了以下錯誤

Error:(25, 13) Failed to resolve: com.google.android.gms:play-services:9.0.1 

我無法找到它的谷歌Play版本安裝的服務。在SDK工具選項卡,它說的版本30

我試過下面這行太多,但它也給了同樣的錯誤

compile 'com.google.android.gms:play-services:30' 

編輯:這是整個的build.gradle文件。

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "ozu.cs394.umurali.whereismycar" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.google.android.gms:play-services:9.0.1' 
} 
+0

其中的SDK工具版本做 你有? – hopeman

+0

我有SDK工具25.1.6 – user3160302

+0

你可以發佈你的'build.gradle'(app)文件 – hopeman

回答

1

你應該更新谷歌在sdk manager發揮服務存儲庫:

enter image description here

+0

好吧,工作。謝謝 – user3160302

0

檢查附加在你的SDK管理器,並確保Google Repository安裝。

11
  • 轉到文件 - >項目結構
  • 選擇 '項目設置'
  • 選擇 '依存關係' 選項卡
  • 點擊 '+',然後選擇 '1.Library依賴'
  • 搜索: com.google.android.gms:play-services
  • 選擇最新版本,然後單擊「確定」
+2

有史以來最佳答案 – Pulkit

+1

謝謝你的回答,我現在可以添加我已安裝的庫,而不用觸摸gradle文件,謝謝 –

相關問題