2

これはトップレベルのGradleファイルでサービスGoogleは、私がグーグルとロケーションAPIを利用したいサービス

を再生する再生取り付け:

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.2.3' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

と、これは私のアプリレベルのGradleファイルです:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.1" 
    defaultConfig { 
     applicationId "..." 
     minSdkVersion 14 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    productFlavors { 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    // androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
    //  exclude group: 'com.android.support', module: 'support-annotations' 
    // }) 
    compile 'com.android.support:appcompat-v7:25.0.1' 
    compile 'com.android.support:design:25.0.1' 
    compile 'com.android.support:recyclerview-v7:25.0.1' 
    compile 'com.google.android.gms:play-services:11.4.2' 
} 

私はプロジェクトをビルドしたい場合は、このエラーが表示:

Error:(30, 13) Failed to resolve: com.google.android.gms:play-services:11.4.2 
Install Repository and sync project 
Show in File 
Show in Project Structure dialog 

私はGoogleが「リポジトリとの同期プロジェクトをインストール」をクリックしてサービスを再生するインストールしましたが、エラーがまだこの文書によると

を示す:私はこの線でグーグル・プレイ・サービスの依存関係を交換した https://developers.google.com/android/guides/setup

compile 'com.google.android.gms:play-services-location:11.4.2' 
compile 'com.google.android.gms:play-services-maps:11.4.2' 

私はプロジェクトをビルドするときに "失敗しました..."というエラーが表示されましたが、「リポジトリのインストールとプロジェクトの同期」をクリックしても何も起こりませんでした。

何が問題ですか?バージョン番号に問題がありますか?または、他の何か ?! HERE書かれているから、

+1

Maven RepoをProject level Gradleに追加しましたか? –

+0

https://stackoverflow.com/questions/46417939/failed-to-resolve-com-google-android-gms-play-services-auth11-4-0 – tyczj

+0

@NovoLucas、私はポストにトップレベルのgradleファイルを追加しました –

答えて

3

、Googleはあなたのプロジェクトは、バージョン25で実行されているので、あなたのプロジェクトcompileSdkVersionは、少なくとも、バージョン26

When you upgrade your app’s Play services dependencies to 11.2.0 or later, your app’s build.gradle must also be updated to specify a compileSdkVersion of at least 26 (Android O). This does not change the way your app runs. You will not be required to update targetSdkVersion.

、に設定する必要がありますバージョン11.2.0からサービスを再生使用します、あなたがgradleでインポートできる最大google playサービスバージョンはバージョン11.0です。

compile 'com.google.android.gms:play-services-location:11.0' 
+0

エラー:(20、0)リポジトリコンテナの引数[]のgoogle()メソッドが見つかりませんでした。 –

+0

編集した投稿をチェックしてください。 26以下のcompileSDKを実行していますか? – Ricardo

+0

私はちょうどあなたの問題の原因を示し、あなたに解決策を与えました – Ricardo

0

あなたは、プロジェクトレベルのGradleファイルに以下を追加する必要があります。

allprojects { 
repositories { 
maven { url "https:// maven.google.com" } 
    } 
} 
//This is when you are using a version of Gradle below 4.1. 

注 - あなたがこれを以下している場合、あなたはまた、あなたのプレイサービスの依存関係のバージョンをダウングレードする必要があります。より良い方法は、最新のコンパイルSDKVersionに更新することです

+3

しばらくの間は 'google()'があります。最近のツールを使用している場合は明示的にURLを設定する必要はありません。 –

+0

しかし2.3.3では動作しません –

+0

更新がある理由 – Ricardo

関連する問題