Android Studioでの設定
過去記載の内容だとうまくいかないので修正
プロジェクトのbuild.gradle
pluginsを新規に追記
plugins {
id 'com.google.dagger.hilt.android' version '2.48' apply false
}
app/build.gradle
plugins {
・・・
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
}
・・・
dependencies {
・・・
implementation "com.google.dagger:hilt-android:2.48"
kapt "com.google.dagger:hilt-android-compiler:2.48"
}
以下は、古い記事。
基本的にはチュートリアルの通りなのだが、少し違っているのでとても迷う。
https://developer.android.com/training/dependency-injection/hilt-android
以下に設定すれば通る
build.gradle
dependencies {
・・・
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
}
app/build.gradle
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
・・・
dependencies {
・・・
implementation "com.google.dagger:hilt-android:2.38.1"
kapt "com.google.dagger:hilt-android-compiler:2.38.1"