Gradle Dependency バージョンのチェックを「最新」に更新する方法

便利そうなのでました!

Android Developers Blog: Announcing new SDK versioning in Google Play services and Firebase

com.google.android.gms:play-services-*
com.google.firebase:firebase-*

に関しては、それぞれが独立したバージョンで記述してよい。

なので、以下のような「バージョンをを揃える」記述は不要。


buildscript {
    ext {
        play_version = '15.0.0'
    }
}

dependencies {
    // DON'T DO THIS!!
    // The following use of the above buildscript property is no longer valid.
    implementation "com.google.android.gms:play-services-auth:${play_version}"
    implementation "com.google.firebase:firebase-auth:${play_version}"
    implementation "com.google.firebase:firebase-firestore:${play_version}"
}

利用方法は以下2パターン。


classpath 'com.google.gms:google-services:3.3.0'

// 最終行
apply plugin: 'com.google.gms.google-services' 

かまたは、


classpath 'com.google.android.gms:strict-version-matcher-plugin:1.0.0'

// 最終行
apply plugin: 'com.google.android.gms.strict-version-matcher-plugin'

とのこと。

 

やってみたが...

エラー。

ビルドできず。


The library com.google.android.gms:play-services-measurement-base
is being requested by various other libraries at [[15.0.0,15.0.0], [15.0.2,15.0.2]],
but resolves to 15.0.2. Disable the plugin and check your dependencies tree
using ./gradlew :app:dependencies.

記述にはない「play-services-measurement-base」が

内部的に呼ばれてこけている。

メッセージに書いてある


./gradlew :app:dependencies

は実行すらできない。

それぞれは、Andrid Studioの自動チェックで最新のはずなのだが。

 

それぞれのバージョンを確認してみる

目視でGoogleリポジトリを確認。

Google's Maven Repository

AndroidStudioの自動チェックで最新版の「15.0.0」だと思っていたが

実は、古いバージョンのままだった。

実際は「15.0.2」が最新。

これに書き換えたらいけた。

しかし、AndroidStudioの自動最新バージョンチェック機能らしきは、

機能してなくね?

かまたは、微妙に古くね?

 

Lint「Newer Library Versions Available」 を確認する

「Preference」-「Editor」-「Inspections」 にある

「Lint」-「Newer Library Versions Available」

OFFになってるが。

Description
Newer Library Versions Available This detector checks with a central repository to see if there are newer versions available for the dependencies used by this project. This is similar to the GradleDependency check, which checks for newer versions available in the Android SDK tools and libraries, but this works with any MavenCentral dependency, and connects to the library every time, which makes it more flexible but also much slower.

「毎回チェックするのでとろい」ということで

デフォルトでOFFになっているのか。

毎回でなく適時、意図的に実行したい場合は、

「Analyze」-「Run Inspection by Name」からいきましょう。

 

グレーのハイライトと同時にツールチップで最新版である

「15.0.2」

をサジェストしてくれました!

【Android Studio】ビルド環境を安定した最新バージョンにする