When we create a simple android app, we can find MainActivity.java in src/com.app.main and R.java in gen/com.app.main (Also, you can define another file or package name, but the format is similar). and from all the indication i found in the code, it seems that src/com.app.main && gen/com.app.main means the same package. why? IMO package is only a folder, and MainActivity.java is in the folder src/com/app/main, R.java is in the folder gen/com/app/main, obviously two different folders, and i think that two different folders mean two different package, anything wrong?
When we create a simple android app, we can find MainActivity.java in src/com.app.main and
Share
First of all, package is not a folder. Source file belongs to the package indicated by the
packageclause at the first line of that file. Creating folder structure that corresponds to the package structure is just a convention.Secondly, when mapping folders to packages folders are treated as relative to their respective base source folders. In your case there are two source folders:
srcfor your sources andgenfor generated sources, and both folders contain subfolders that correspond to the same package.