SharedTest got warning "Duplicate content root detected" on Android Studio Chipmunk

Issue

After upgrade to Android Studio Chipmunk, my test failed because I can’t access file inside shared folder that defined in build.gradle like this.

sourceSets {
    androidTest.java.srcDirs += "src/sharedTest/java"
    test.java.srcDirs += "src/sharedTest/java" }

It show warning pop up with message "Duplicate content root detected". Path [sharedTest] of module [unitTest] was removed from modules [androidTest]. Anyone can resolve this?

Solution

According to https://issuetracker.google.com/issues/232007221 ("Duplicate content roots detected" with Android Gradle plugin 7.2.0) Google no longer supports this construct in Android Studio Chipmunk 2021.2.1.

https://issuetracker.google.com/issues/232007221#comment17 says "Source sets can no longer contain shared roots as this is impossible to represent in the IDE."

To follow the on-going discussions, subscribe to
https://issuetracker.google.com/232007221 and
https://issuetracker.google.com/232420188

Answered By – MikeMcC399

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published