Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.<classes> but it asks me to rename it to main.src.com.example.<classes> 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')
    }
like image 606
Quentin Avatar asked Jul 17 '13 11:07

Quentin


People also ask

How do I rename a package in IntelliJ?

Rename a package In the Project tool window, click Project and select Packages from the list. IntelliJ IDEA lists all the packages in your project. Right-click the package you want to rename and from the context menu, select Refactor | Rename ( Shift+F6 ).

What is the IML file in IntelliJ?

A module file (the . iml file) is used for keeping module configuration. Modules allow you to combine several technologies and frameworks in one application. In IntelliJ IDEA, you can create several modules for a project and each of them can be responsible for its own framework.


1 Answers

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'].

like image 59
Vindicator Avatar answered Oct 02 '22 16:10

Vindicator