2

I am new to Java and to Android development. In all the tutorials at my current level of understanding, the only user-created classes are found in the directory app/src/main/java/com.example.project/, and all these classes refer to views.

In my project, I will need to write a number of classes which are not directly related to any particular views. For example, a TextToSpeech class and a PatternRecognition class.

What are considered to be the best practices for managing the class files in the directory hierarchy? What online resources can you recommend, so that I can explore this question in more detail?

jww
  • 97,681
  • 90
  • 411
  • 885
James Newton
  • 6,623
  • 8
  • 49
  • 113
  • Check this topic about mvc project structure: http://stackoverflow.com/questions/12397940/spring-and-mvc-proper-project-structure – Ismael Di Vita Oct 25 '14 at 12:26

2 Answers2

3

I suggest to read this article http://fernandocejas.com/2014/09/03/architecting-android-the-clean-way/.

And take a look on this repository https://github.com/android10/Android-CleanArchitecture.

Anton Holovin
  • 5,513
  • 1
  • 31
  • 33
  • Thanks Anton. This article is about how to separate the different layers of a project, not about how the files that implement those layers arranged hierarchically in a directory structure. The answer to my question appears to be: Put all classes in the java/ directory, arranged in the hierarchy that makes most sense to the development team. – James Newton Oct 25 '14 at 13:35
  • @JamesNewton, you can check hierarchy in the repository. And this hierarchy looks similar to Nagy Vilmos's answer. – Anton Holovin Oct 25 '14 at 13:39
1

I'm not sure, that this is the best way, but my Android projects looks like this:

src
├───androidTest
│   └───java
│       └───hu
│           └───company
│               └───app
│                   └───activities
│                       ├───login
│                       └───main
└───main
    ├───assets
    │   └...
    ├───java
    │   └───hu
    │       └───company
    │           └───app
    │               ├───activities
    │               │   ├───login
    │               │   ├───main
    │               │   ├───mainMenu
    │               │   └───surveys
    │               ├───common
    │               └───communication
    └───res
        └──...

And in the hu.company.app package, I have more packages. All of my Activities in the activities package, sorted by their functionality. And I have other classes in upper packages.

When I started this project, I could'nt find any docs about the "best" Android project structure. I'm not sure, that this is a right project structure, but it works.

Nagy Vilmos
  • 1,878
  • 22
  • 46