Group Group Group Group Group Group Group Group Group

Clean Architecture Tutorial for Android: Getting Started |

In this tutorial, you’ll learn how to use Clean Architecture on Android to build robust, flexible and maintainable applications.

This is a companion discussion topic for the original entry at

Great tutorial!! Thanks :slight_smile:

GlobalScope not work, can you update the tutorial please? Thank you for share your knowledges.

Correction* I dont know why but GlobalScope bugs import. Download again and sync works!

@cryptoseven Glad you like it! Cheers! :]

@nicolaugalves Glad you sorted it out! Cheers! :]

I think the tutorial its really nice
I just have a concern:
why are you using Serializable instead of Parcelabe for the models is there any reason in specific?

thanks, I’m glad you like the tutorial! :]

I’m using Serializable only because it’s easier to implement - wanted to keep the code in sample project as simple as possible.

Awesome article! One thing I would have liked to have seen though is at least a little bit more of a reference to how the data provider is abstracted. Specifically, maybe a diagram making it clear that you might have both network and local DB acting as data providers, and that it’s the responsibility of the Repository to figure out which to use and how to sync between them.

kind of like this. I realize the implementation for this is probably out of scope for a tutorial article like this, though but some reference on how to approach this common pattern or where to go for examples would be great.

I realize this probably happened during course of writing the article - you started out with a project structure with a certain name but in packaging the tutorial for starter / final projects things may have changed. In the point of the tutorial where you first have the reader do stuff in Android Studio, you say:

Right click on MajesticReader in Project explorer and select New ▸ Module or select File ▸ New ▸ New Module

This is incorrect in relation to the project the reader actually downloads, and the screenshots are also incorrect.

The only folder named majestic reader is too far down on the hierarchy. Comparing to the final project, the place they should be creating the new module is at the project root.

Actually, I can’t get the starter or final projects to run. Opening them in Android Studio, it says “module not specified” and there is no module to choose from. Something seems to be missing from the project files to get the projects to work out of the box?

Also, the final project code does not match the code as per the tutorial. For example, there is a step which says:

Open MajesticReaderApplication and replace onCreate() with the following, making sure you add all the necessary imports:

The code from this step is nowhere to be found in the final project. It seems perhaps the wrong code was submitted for the final project?

Hi @abunur thanks for the question!

I uploaded a new version of the tutorial materials that should have addressed this problem. Let us know if you’re still unable to build the project in Android Studio 3.5 or later.

Also, the MajesticReaderApplication class is in the framework package of the app module.

Thanks again!

1 Like

@macsimus @ikust
Great article! But I am curious to know why did you use GlobalScope instead of viewModelScope?

Hi @sagarsuri,
thanks for the question! I’m glad that you like the article :slight_smile:

viewModelScope would be the appropriate scope to use but it was added in version 2.1.0 of androidx.lifecycle:lifecycle-viewmodel-ktx library which wasn’t available at the time of writing. To keep things as simple as possible we used GlobalScope.

1 Like

Where is the right place for di folder to reside?

@sagarsuri If you are referring to a folder that would hold Dependency Injection related code, the right place for it is framework package in the app module.