Dagger Hilt --Error: annotation @AggregatedRoot is missing a default value for the element 'originatingRoot'--

Viewed 2802

Im using Dagger Hilt in my project and its not compilating. Checked everything in manifest and project files and have no idea what is happenning :/

error: annotation @AggregatedRoot is missing a default value for the element 'originatingRoot'
@AggregatedRoot(
^warning: File for type 'com.example.mikebamb.EquipmentsApplication_HiltComponents' created in the last round 
will not be subject to annotation processing.warning: File for type 'dagger.hilt.internal.processedrootsentinel.codegen._com_example_mikebamb_EquipmentsApplication' 
created in the last round will not be subject to annotation processing.
> Task :app:kaptDebugKotlin FAILED

EquipmentsApplication Cass

@HiltAndroidApp
class EquipmentsApplication : Application()

Main Activity

@AndroidEntryPoint
class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }
}

Manifest File

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mikebamb">

    <application
        android:name="com.example.mikebamb.EquipmentsApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MikeBamb">
        <activity android:name=".presenter.MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
4 Answers

For some reason my versions of the implementation were not matching

Old Version

implementation 'com.google.dagger:hilt-android:2.36'
kapt 'com.google.dagger:hilt-compiler:2.35.1'

Rolled back to

implementation 'com.google.dagger:hilt-android:2.35'
kapt 'com.google.dagger:hilt-compiler:2.35'

Check the dependency version in both the build(project) and build (module) they must be of the same version

In Project plugins { //hilt id 'com.google.dagger.hilt.android' version '2.42' apply false }

In module

plugins {
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}  

 composeOptions {
 kotlinCompilerExtensionVersion = "1.2.0-beta03"
 }

dependencies {
implementation 'com.google.dagger:hilt-android:2.42'
implementation 'androidx.hilt:hilt-work:1.0.0'
kapt "com.google.dagger:hilt-compiler:2.42"
kapt 'androidx.hilt:hilt-compiler:1.0.0'
implementation 'androidx.hilt:hilt-navigation-fragment:1.0.0'
}

Make sure that all the dependencies versions are matching.

Project's build.gradle's

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

and module's build.gradle's

implementation "com.google.dagger:hilt-android:2.42"

kapt "com.google.dagger:hilt-android-compiler:2.42"

Must all be on the same version. I initially got this error after updating all my Dagger-Hilt dependencies but erroneously forgot to update the one for the kapt compiler since the IDE didn't warn me about it being outdated, updating all three to the same version fixed it.

I faced the same error in Hilt 2.42 version.

Then I rolled back to 2.38.1 for all hilt dependency

Error gone

Related