David
David

Reputation: 54

Folder structure in empty project. (No activities created, esp, main_activity)

What is the use of the "src/main" folder in a blank project. I prefer flat folder hierarchies, so i am a little bit confused of that.

The subfolder "main" for me only makes sense in relation of the main_activity conetxt. So anyone can explain me the use of this unruly folder ;-)

PS. Removing it will cause several exeptions and gradle error, because the whole folder structure is blueprinted in several *.iml files

Upvotes: 0

Views: 65

Answers (1)

Scott Barta
Scott Barta

Reputation: 80010

There's documentation on project structure here:

http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Project-Structure

In a nutshell, the build system allows you to have build types and flavors, and those configurations can have their own source trees (which are added to/merged with the main source tree, not a replacement for it); src/main is the main source folder, and if you have flavors flavor1 and flavor2, you can have source directories src/flavor1, src/flavor2, and so on.

What are these build types and flavors? A flavor is a variation of your application that is similar but functionally different -- a common example might be a free version vs. a paid version. A build type is something that's functionally equivalent, but might differ in debugging or diagnostic code: debug vs. release versions.

If you have a simple application, then the flavors might not be a useful concept to you, but it's useful enough to a significant number of developers, so it's a first-class concept in the build system. Debug vs. release build types are something that's useful to most developers, I think, and it's something you should consider taking advantage of. That encompasses not just debugging code in your app, but also how the build is signed, whether it uses ProGuard, and other considerations for releasing your app to the world.

If you prefer a flatter directory structure, you can manually change the directories via the build file (see Configuring the Structure in that link), but I'd recommend sticking with the default until you're more familiar with how the build system works.

Upvotes: 2

Related Questions