Quentin Quentin - 2 months ago 39
Android Question

Package name does not correspond to the file path

My android studio project is compiling as it should, but there's one annoying issue.
Android studio gives me this warning:

Package name does not correspond to the file path


the file path declared in the source code is something like com.example.
but it asks me to rename it to main.src.com.example.
When I do that, it no longer compiles

My source code is in the src/main/src folder

my build.gradle contains this

sourceSets {
main {
java.srcDirs = ['src']
}

instrumentTest.setRoot('tests')
}

Answer

Since your gradle.build file is in the main directory, it views the first src folder as the one containing the source. Try changing java.srcDirs to ['src/main/src'].