Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android-compiler dependency was found

I'm getting the error "The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android-compiler dependency was found." while building the project.

Here's how I'm adding hilt to my project.

enter image description here

enter image description here

enter image description here

enter image description here

like image 255
Feroz Khan Avatar asked Jul 13 '20 19:07

Feroz Khan


People also ask

What is Dagger and Hilt in Android?

Hilt provides a standard way to incorporate Dagger dependency injection into an Android application. The goals of Hilt are: To simplify Dagger-related infrastructure for Android apps. To create a standard set of components and scopes to ease setup, readability/understanding, and code sharing between apps.

What are Gradle plugins?

A plugin is simply any class that implements the Plugin interface. Gradle provides the core plugins (e.g. JavaPlugin ) as part of its distribution which means they are automatically resolved. However, non-core binary plugins need to be resolved before they can be applied.

What is Hilt kotlin?

Hilt is a new dependency injection library built on top of Dagger that simplifies its use in Android apps. This guide showcases the core functionality with a few code snippets to help you get started with using Hilt in your project.


1 Answers

I guess you re missing this dependency

kapt "com.google.dagger:hilt-android-compiler:2.28-alpha"

*First add the plugin

apply plugin: 'dagger.hilt.android.plugin'

*Secondly add the dependencies

// Dagger Core implementation "com.google.dagger:dagger:2.37" kapt "com.google.dagger:dagger-compiler:2.37"  // Dagger Android api 'com.google.dagger:dagger-android:2.37' api 'com.google.dagger:dagger-android-support:2.37' kapt 'com.google.dagger:dagger-android-processor:2.37'  // Dagger - Hilt implementation "com.google.dagger:hilt-android:2.37" kapt "com.google.dagger:hilt-android-compiler:2.37" 

*Thirdly add the classpath

classpath "com.google.dagger:hilt-android-gradle-plugin:2.28-alpha"

PS : if you re using java replace kapt with annotationProcessor

like image 79
Taki Avatar answered Sep 20 '22 19:09

Taki