Home > Enterprise >  How to add depedency dagger hilt in new Android Studio Eel?
How to add depedency dagger hilt in new Android Studio Eel?

Time:09-15

So I updated my android studio version from Dolphin to the newest one (Eel)

build.gradle (project) only contains plugins (no buildscript, repositories, and dependencies):

plugins {
    id 'com.android.application' version '7.2.2' apply false
    id 'com.android.library' version '7.2.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}

and the build.gradle (module)

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

I am confused because when I put this code in the build.gradle

build.gradle(project)
plugins {
    id 'com.google.dagger.hilt.android' version '2.43.2' apply false
}

and

build.gradle(app)
plugins {
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}

dependencies {
    // Dagger - Hilt
    implementation "com.google.dagger:hilt-android:2.43.2"
    kapt "com.google.dagger:hilt-android-compiler:2.43.2"
}


the error shown

* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'com.google.dagger.hilt.android', version: '2.42', apply: false] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact 'com.google.dagger.hilt.android:com.google.dagger.hilt.android.gradle.plugin:2.42')
  Searched in the following repositories:
    Google
    MavenRepo
    Gradle Central Plugin Repository

CodePudding user response:

In your Build.Gradle (Project level)

buildscript {
//Your dependencies ...
    dependencies {
        classpath "com.google.dagger:hilt-android-gradle-plugin:2.38.1"

    }
}
 //Your plugins ...
plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
    id 'org.jetbrains.kotlin.android' version '1.6.21' apply false
}
  • Related