1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

(自分用メモ)【Gradle】推移的依存関係の解決

Posted at

推移的依存(transitive dependency)とは?

アプリで依存しているライブラリ A があった時、そのライブラリ A が内部でライブラリ B に依存している時、アプリは「ライブラリ B に推移的に依存している」と言う。
この図の場合、Library A と Library B はそれぞれ Library C に依存しているため、 Your App は Library C に推移的依存していると言える。

スクリーンショット 2025-04-08 23.57.05.png
(出典:https://developer.android.com/build/gradle-dependency-resolution?hl=ja)

しかし、この図だと Library A と Library B がそれぞr Library C の異なるバージョンを使用してしまっている。こういった状態は「バージョンが競合している」と表現される。

Gradle はこうして競合が発生した場合、デフォルトでは最も高いバージョンを選択することで競合を解決する。

Gradle considers all requested versions across the dependency graph and, by default, selects the highest version. Detailed version ordering is explained in version ordering.

(出典:https://docs.gradle.org/current/userguide/dependency_resolution_model.html)

推移的依存関係を調べる

./gradlew app:dependencies コマンドを打つことですべての依存関係のツリーが表示される。
->が表示されているライブラリは推移的依存関係の解決によって想定していないバージョンが使用されている。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?