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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With