Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building an Android UI test module with more than 1 UI test fails on ':uitest:hiltAggregateDepsDebug' #3478

Closed
vpuonti opened this issue Jul 22, 2022 · 4 comments · May be fixed by #3521
Closed

Comments

@vpuonti
Copy link

vpuonti commented Jul 22, 2022

Hi,

We started adding Jetpack Compose to our project and while doing that, also updated Hilt from 2.38.1 to 2.42.
Now our :uitest module is not building due to an error:

Execution failed for task ':uitest:hiltAggregateDepsDebug'.
> A failure occurred while executing dagger.hilt.android.plugin.task.AggregateDepsTask$WorkerAction
   > Collection has more than one element.

Hilt 2.39 is the latest version that works fine. I checked the release notes for what could be the cause, and saw that Hilt 2.40 turned on enableAggregatingTask by default.
I think that change might be the reason I'm facing this error, but I'm not so knowledgeable on "compilation units" etc to apply the info written here (Sharing Test Components) to the issue I'm facing.

Do I need to change the way I structure my tests?
Do I need to pass some flags?
Is disabling enableAggregatingTask a possibility and will that have some adverse effects down the line?

I've created a repro project which is hosted here: https://github.com/vpuonti/hilt-ui-test-repro

Thanks in advance!

@vpuonti
Copy link
Author

vpuonti commented Jul 22, 2022

Adding

hilt {
    enableAggregatingTask = false
}

to uitest/build.gradle fixes the issue, so it seems the issue is resolved!

I would still like to know if that is the recommended approach when you have UI tests in their own module.

@bcorso
Copy link

bcorso commented Jul 22, 2022

Hi @vpuonti, this sounds like it could be a duplicate of #3464, which should be fixed in Dagger 2.43.

Can you try upgrading to 2.43 and see if it fixes your issue without having to set enableAggregatingTask = false?

@vpuonti
Copy link
Author

vpuonti commented Jul 25, 2022

Hi @bcorso I upgraded to Hilt 2.43 but the issue still persists.

@danysantiago
Copy link
Member

It seems that the issue is Hilt's task configuration not considering the sources in src/main of the com.android.test module as tests and we didn't expect to find @HiltAndroidTest annotated classes in there. Likely a regression from the previous strategy for aggregating the compile classpath.

As a workaround you can instead move the test module to a com.android.library one, moving the tests sources to androidTest along with the dependency declarations from implementation to androidTestImplementation.

@danysantiago danysantiago self-assigned this Jul 25, 2022
copybara-service bot pushed a commit that referenced this issue Jul 26, 2022
…e task for a com.android.test Gradle module.

Fixes: #3478
RELNOTES=Fix an issue in Hilt's Gradle Plugin not configuring the aggregating task correctly on a com.android.test Gradle module.
PiperOrigin-RevId: 463330712
copybara-service bot pushed a commit that referenced this issue Jul 26, 2022
…e task for a com.android.test Gradle module.

Fixes: #3478
RELNOTES=Fix an issue in Hilt's Gradle Plugin not configuring the aggregating task correctly on a com.android.test Gradle module.
PiperOrigin-RevId: 463330712
copybara-service bot pushed a commit that referenced this issue Jul 26, 2022
…e task for a com.android.test Gradle module.

Fixes: #3478
RELNOTES=Fix an issue in Hilt's Gradle Plugin not configuring the aggregating task correctly on a com.android.test Gradle module.
PiperOrigin-RevId: 463330712
copybara-service bot pushed a commit that referenced this issue Jul 26, 2022
…e task for a com.android.test Gradle module.

Fixes: #3478
RELNOTES=Fix an issue in Hilt's Gradle Plugin not configuring the aggregating task correctly on a com.android.test Gradle module.
PiperOrigin-RevId: 463330712
copybara-service bot pushed a commit that referenced this issue Jul 26, 2022
…e task for a com.android.test Gradle module.

Fixes: #3478
RELNOTES=Fix an issue in Hilt's Gradle Plugin not configuring the aggregating task correctly on a com.android.test Gradle module.
PiperOrigin-RevId: 463330712
copybara-service bot pushed a commit that referenced this issue Aug 10, 2022
…e task for a com.android.test Gradle module.

Fixes: #3478
RELNOTES=n/a
PiperOrigin-RevId: 466709073
copybara-service bot pushed a commit that referenced this issue Aug 10, 2022
…e task for a com.android.test Gradle module.

Fixes: #3478
RELNOTES=Fix an issue in Hilt's Gradle Plugin not configuring the aggregating task correctly on a com.android.test Gradle module.
PiperOrigin-RevId: 463330712
copybara-service bot pushed a commit that referenced this issue Aug 10, 2022
…e task for a com.android.test Gradle module.

Fixes: #3478
RELNOTES=Fix an issue in Hilt's Gradle Plugin not configuring the aggregating task correctly on a com.android.test Gradle module.
PiperOrigin-RevId: 463330712
copybara-service bot pushed a commit that referenced this issue Aug 10, 2022
…e task for a com.android.test Gradle module.

Fixes: #3478
RELNOTES=Fix an issue in Hilt's Gradle Plugin not configuring the aggregating task correctly on a com.android.test Gradle module.
PiperOrigin-RevId: 463330712
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment