Tips on organizing larger Android projects?

Zsombor Erdődy-Nagy picture Zsombor Erdődy-Nagy · Apr 11, 2011 · Viewed 12.1k times · Source

My current project is getting awfully large. I have dozens of activities, adapters, fragments, layout xmls, and other resources.

In my (smaller) previous projects I organized stuff with a 1 package / 1 category style. So I had com.stuff.xy.adapter, com.stuff.xy.activity, and so on. Now these packages contain too many items, and I find myself wasting considerable amounts of time searching for a specific class in the package hierarchy.

I use Eclipse, and there are some shortcuts one can use (go to class definition e.g.), but those tend to be situational (I can't use that to quickly jump to a layout definiton xml).

Could you share some tips on organizing large scale projects efficiently? Or some plugins for this perhaps? (It might help for example if I could group together source files that deal with a specific application screen - adapters, layouts, activity and fragment code - so I can quickly open them)

EDIT: After many months developing large projects

First I tried to go with working sets with Eclipse. It didn't really cut it for me, my problem was that our single Android project was simply too big, containing many resources, classes, interfaces, etc. Messing around with working sets in the context of a single project just took too much time, I think that they're mainly useful to organize projects in a single workspace.

On the long run we separated our huge single project into many smaller android-library projects and a single "main application" project that depended on all these smaller ones. This way we could split the resources among these library projects (there were many layouts, values, styles that were only used in certain parts in the application) and code of course. I also created a Base library, that all other libraries depended upon, and contained resources and (base)classes that every part of the application needed.

Answer

Vladimir Ivanov picture Vladimir Ivanov · Apr 11, 2011

For all my android projects I prefer to sort code in the following structure:

com.company.projectname is the package of the application. Underlying packages:

model - all my business-objects

logic - services and objects implementing business logic

screens - all the activities of the project. If activities require adapters and so on, then each activity is placed in a separate package under screens package and the related stuff is placed to the same project.

tools - package with Utility class. SettingsUtil and so on.

In the root of the package I usually have Constants.java interface with constants.