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."
The following comment has been removed: "In order to share sources between test and androidTest you should be able to use test fixtures."
There has been an update to the issue:
"The recommended solution to this issue is not using test fixtures (this is not what they are intended for).
The current recommendation is to use a separate com.android.library Gradle project to store any shared code required across test and androidTest.
Note: You will not be able to access things marked internal which would have been accessible before.
Please see more information in: https://issuetracker.google.com/232420188 "
In summary, to follow the on-going discussions, subscribe to
https://issuetracker.google.com/232007221 and
https://issuetracker.google.com/232420188
Answered By - MikeMcC399
Answer Checked By - Marie Seifert (JavaFixing Admin)