Organizing resources for an Android project into several packages

I am working on an Android project using Eclipse. The project contains several modules that connect to the central core, and it would be advisable to organize them into subpackages, for example.

com.example.myapp - containing main classes and actions

com.example.myapp.module1 - classes and actions related to module 1

com.example.myapp.module2 - classes and actions related to module 2

etc. Since each module cannot work independently, everything is included in one Eclipse project.

Now it would be great to organize resources in separate packages. At the moment, all my layouts and drawings are precompiled in com.example.myapp.R .

Is there a way to organize a project so that Eclipse automatically puts resources for module 1 in com.example.myapp.module1.R , etc.?

+4
source share
1 answer

com.example.myapp.module2.SomeClass are the names of the Java packages, and you can freely choose them for each class. You don’t even have to start with com.example.myapp .

But com.example.myapp.R is created from the package name defined in your AndroidManifest.xml , and this is fixed as this package name defines your application and the resources belonging to the application. As far as I know, there is no way to split this into other packages (if you save it in one project).

However, if you use library projects to be included in your application, you may have different .R s.

+1
source

All Articles