google / dagger

A fast dependency injector for Android and Java.
https://dagger.dev
Apache License 2.0
17.4k stars 2.01k forks source link

after add hilt { enableAggregatingTask = true } dependencies tasks faild #2787

Closed cquin89 closed 3 years ago

cquin89 commented 3 years ago

when I add the line hilt { enableAggregatingTask = true} error (Execution failed for task ':app:dependencies) happend

Execution failed for task ':app:dependencies'. Cannot change dependencies of dependency configuration ':app:hmsDebugAndroidTestRuntimeClasspath' after it has been included in dependency resolution. Use 'defaultDependencies' instead of 'beforeResolve' to specify default dependencies for a configuration.

The task fails when I add a flavor that starts with a letter greater than g

Example:

flavorDimensions "version" productFlavors{ hms{ dimension "version" } gms{ dimension "version" } }

uhooi commented 3 years ago

I had the same build error.
https://github.com/uhooi/UhooiPicBook-Android/runs/3291487872?check_suite_focus=true

> Task :app:getDependencies FAILED

1 actionable task: 1 executed
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:getDependencies'.
> Cannot change dependencies of dependency configuration ':app:productionDebugAndroidTestRuntimeClasspath' after it has been included in dependency resolution. Use 'defaultDependencies' instead of 'beforeResolve' to specify default dependencies for a configuration.

After removing the production flavor, the build was successful.
https://github.com/uhooi/UhooiPicBook-Android/runs/3295567631?check_suite_focus=true

android {
    flavorDimensions 'environment'
    productFlavors {
-       production {
-           dimension 'environment'
-       }
        develop {
            dimension 'environment'
            applicationIdSuffix '.develop'
            versionNameSuffix '-develop'
        }
    }
}

But the production flavor is required, so enableAggregatingTask flag cannot be added now.

danysantiago commented 3 years ago

Thanks for the repro project, I'll take a look at this soon.

danysantiago commented 3 years ago

By the way, I think this is a dupe of https://github.com/google/dagger/issues/2744, but need to look deeper.

danysantiago commented 3 years ago

Definitely a dupe of https://github.com/google/dagger/issues/2744, closing as dupe.