How to add classpath hilt-android-gradle-plugin in android studio chipmunk and higher

Viewed 255

earlier we could add dagger-hilt using this in root build.gradle file:

buildscript {
    ...
    dependencies {
        ...
        classpath 'com.google.dagger:hilt-android-gradle-plugin:2.38.1'
    }
}

how can we add this in android studio chipmunk and higher

2 Answers
id 'com.google.dagger.hilt.android' version '2.43' apply false

You can use this code

First, add a Plugin in Root level Gradle like below

plugins {
  // other plugins...
  id 'com.google.dagger.hilt.android' version '2.43.2' apply false
}

And then add Plugin in App level Gradle like below

plugins {
  // other plugins...
  id 'com.android.application'
  id 'com.google.dagger.hilt.android'
}

For reference please read this documentation: https://dagger.dev/hilt/gradle-setup

Related