LoginSignup
25
14

More than 5 years have passed since last update.

3.0.0-alpha以降のAndroidプラグインはGoogleのmavenリポジトリで取得する必要がある

Last updated at Posted at 2017-06-07

Googleの出してるリリースノート+ドキュメント、きちんと読もう!(自戒)

概要

Google I/O 2017で発表されましたが、Googleからmavenリポジトリが提供され、いくつかのプラグインなどはここからダウンロードする形になりました。

すでにこの提供は始まっていて、3.0.0-alpha1以上のandroid-toolsのgradleやサポートライブラリなど、いくつかの最新版のプラグインはもうjcenterでは提供されておらず、mavenリポジトリから取得しなければいけません。

コードサンプル

rootProject/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()

        // 追加
        maven {
            url 'https://maven.google.com'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0-alpha3'

        classpath 'com.google.gms:google-services:3.1.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

// 追加
repositories {
    maven {
        url 'https://maven.google.com'
    }
}

android {
    // 以下、省略

以上です。

追記

「全てのプロジェクトでgoogleリポジトリ読み込める対象にするぞ!」っていう話であれば、 allprojects内にて設定してしまえばいいと思います。
また、mavenのurl指定ではなく google() でも読み取れるみたいですね。

rootProject/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

        classpath 'com.google.gms:google-services:3.1.0'
    }
}

allprojects {
    repositories {
        google() // 追加
        jcenter()
    }
}

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
25
14