Reputation: 7193
I was looking through a sample project project provided by the android developer website and I see that a file Beam.java
has been declared in a package as package com.example.android.beam;
with the folder structure "..\src\com\example\android\beam\Beam.java". There are two other files, BuildConfig.java
and R.java
in a similar directory structure, but in a completely different directory "..\gen\com\example\android\beam\Beam.java" but with the same package declaration of package com.example.android.beam;
. Are all these files in the same package even though they are in different folders? Did the IDE put the latter two files in a different folder only to make it clear that they are autogenerated, or is there a another reason as well?
Upvotes: 2
Views: 943
Reputation: 117587
can files in different folders be in the same package?
Yes, as long as they all are compiled and packaged to be in the same directory in the .dex file.
Upvotes: 1
Reputation: 3910
The folder called "gen" is an automatically generated folder which contains files that are also automatically generated. In other words, don't worry about the "gen" folder, your packages and files and whatever you make will be in the "src" folder.
For example, the Android IDE generates the file "R.java" which contains the element id's used in your code, ie. "R.id.some_element", "R.string.some_string".
Upvotes: 2
Reputation: 2470
They are autogenerated so as you said, they are put in /gen/... . What YOU write must be put in /src/...
Upvotes: 1