🐚
Android開発Hilt導入でhiltAggregateDepsDebug FAILEDが発生したときの対処
したかったこと
Android 開発でDagger-Hilt
を導入したかった
したこと
libs.version に追加
[versions]
hilt = "2.56"
[libraries]
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
hilt-compiler = { group = "com.google.dagger", name = "hilt-compiler", version.ref = "hilt" }
build.gradleに追加
plugins{
alias(libs.plugins.hilt)
}
dependencies {
implementation(libs.hilt.android)
ksp(libs.hilt.compiler)
}
発生したこと
Unable to find method ''java.lang.String com.squareup.javapoet.ClassName.canonicalName()''
'java.lang.String com.squareup.javapoet.ClassName.canonicalName()'
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)
Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.
In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
適当な意訳↓
java.lang.String com.squareup.javapoet.ClassName.canonicalName()がないよ!
Gradleの依存性はなんかおかしいからキャッシュ消すなり再起動するなりしてみて
対応
根本的な問題はhilt内部で利用しているJavaPoetのバージョンが合っていないことらしい
canonicalName()
がJavaPoet 1.15.0 以降に追加されたものなので見つからないことがあるみたい
build.gradleに
hilt {
enableAggregatingTask = false
}
を追加し、ビルドエラーが回避できる。ただし一時的なもののよう。
----以下曖昧
Aggregating Task
は依存性注入などをまとめて実行し、依存関係がわかりやすい
fales にするとIsolating Task
になり、各コンポーネントを独立してビルドできるようになるみたい。
そのためバージョン違いによるエラーが回避できているっぽい。
Discussion