Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tips on organizing larger Android projects?

Tags:

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.

like image 852
Zsombor Erdődy-Nagy Avatar asked Apr 11 '11 15:04

Zsombor Erdődy-Nagy


2 Answers

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.

like image 110
Vladimir Ivanov Avatar answered Jan 05 '23 20:01

Vladimir Ivanov


In Eclipse, you can use Working Sets to filter your source/layout/resource files in the Project Explorer view. This is a bit more powerful than packages, since it operates on all files including layout and image assets, not just java source files.

For example, you could create a Home working set which contains HomeActivity.java, HomeAdapter.java, res/layout/home.xml, res/drawable/home_icon.png, etc.

like image 22
Graham Borland Avatar answered Jan 05 '23 20:01

Graham Borland