Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can you use Hilt in a Java-only Android project?

According to the official integration guide, you need to add

plugins {
  id 'kotlin-kapt'
  ...
}

and

dependencies {
    implementation "com.google.dagger:hilt-android:{hilt_version}"
    kapt "com.google.dagger:hilt-compiler:{hilt_version}"
}

to your build.grade file. However, when I do a gralde sync, I get the following error:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Plugin [id: ‘kotlin-kapt’] was not found in any of the following
sources:

is it possible to use Dagger-Hilt in a pure java project? Or do you have to either use plain Dagger or use Kotlin?

>Solution :

Yes, you can use the following instead of kotlin-kapt:

dependencies {
    implementation "com.google.dagger:hilt-android:{hilt_version}"
    annotationProcessor 'com.google.dagger:hilt-compiler:{hilt_version}'
}


plugins {
    id 'dagger.hilt.android.plugin'
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading