The sourceSets
block needs to be inside the android
block for Android build files. Note that this is different from plain Java builds, where that block goes at the top level:
android {
...
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src-gen/main/java']
}
}
}
As you've seen, editing the .iml files directly doesn't work for long -- those get overwritten every time Android Studio syncs the Gradle files with the project, which is somewhat often.