Android-CleanArchitecture | sample app that is part of a series of blog posts | Architecture library

 by   android10 Java Version: v0.9.5 License: Apache-2.0

kandi X-RAY | Android-CleanArchitecture Summary

kandi X-RAY | Android-CleanArchitecture Summary

Android-CleanArchitecture is a Java library typically used in Architecture applications. Android-CleanArchitecture has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. However Android-CleanArchitecture has 3 bugs. You can download it from GitHub.

This is a sample app that is part of a series of blog posts I have written about how to architect an android application using Uncle Bob's clean architecture approach.

            kandi-support Support

              Android-CleanArchitecture has a medium active ecosystem.
              It has 15331 star(s) with 3370 fork(s). There are 845 watchers for this library.
              It had no major release in the last 6 months.
              There are 126 open issues and 124 have been closed. On average issues are closed in 157 days. There are 16 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of Android-CleanArchitecture is v0.9.5

            kandi-Quality Quality

              Android-CleanArchitecture has 3 bugs (2 blocker, 0 critical, 0 major, 1 minor) and 47 code smells.

            kandi-Security Security

              Android-CleanArchitecture has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              Android-CleanArchitecture code analysis shows 0 unresolved vulnerabilities.
              There are 3 security hotspots that need review.

            kandi-License License

              Android-CleanArchitecture is licensed under the Apache-2.0 License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              Android-CleanArchitecture releases are not available. You will need to build from source code and install.
              Build file is available. You can build the component from source.
              Installation instructions are not available. Examples and code snippets are available.
              Android-CleanArchitecture saves you 1362 person hours of effort in developing the same functionality from scratch.
              It has 3051 lines of code, 379 functions and 95 files.
              It has low code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed Android-CleanArchitecture and discovered the below as its top functions. This is intended to give you an instant insight into Android-CleanArchitecture implemented functionality, and help decide if they suit your requirements.
            • Download image from url .
            • Gets user entities .
            • Read the file content .
            • Retrieve user entity from cache .
            • Transform users model .
            • Connect to API
            • Creates a message from the given exception .
            • sets the onBindViewHolder on the ListViewHolder
            • Renders the user model .
            • Gets the error message .
            Get all kandi verified functions for this library.

            Android-CleanArchitecture Key Features

            No Key Features are available at this moment for Android-CleanArchitecture.

            Android-CleanArchitecture Examples and Code Snippets

            No Code Snippets are available at this moment for Android-CleanArchitecture.

            Community Discussions


            In clean MVP, who should handle combining interactors?
            Asked 2019-Apr-12 at 16:21

            I've seen good examples of MVP architecture (here and here). Both present only simple interactors, but I wonder how to deal with more complex use case, consisting of steps, which are repeated in other use cases.

            For example, my API requires token to authenticate any call. I've created an interactor to get that token (GetToken). I want to get user's last login date (GetLastLoginDate) and then fetch a list of changes that occured between that date and now (GetVersionChanges).

            Where those interactor should be chained? I want to keep them separate, because some of them are reused in other parts of the code. I've came up with two solutions.

            1. Presenter should chain all interactors. This solution works as long the use case is not complex and doesn't have many preconditions. It seems to me it's not the right place, because it burdens presenter with another responsibility.

            2. Interactor can use many repositories (no clean architecture rules are broken then). Why not use TokenRepository in other interactors? Because getting token is much more complex than just reaching to repository. Repeating the steps in other interactor does not reuse already existing code.

            Both solutions have their flaws and are against basic principles (DRY, single responsibility principle).



            Answered 2019-Apr-12 at 16:21

            If I were you I would just put the logic of getting a token in a separate interactor (maybe named getTokenInteractor) and call that interactor from your others interactor who may need it. That way, it would be in an interactor that you chose either to use a token (and call or not your getTokenInteractor) and also in an interactor that you retrieve it and deal with errors. I would do the same for your "getVersionChanges" use case and let an interactor chain the calls.

            Let's imagine you have a presenter who needs to display the version changes. He will call a first interactor (GetVersionChangesInteractor) who will first check if he has a token (by calling getTokenInteractor), then call GetLastLoginDateRepository for retrieving the date, and call GetVersionChangesRepository with that date and finally give the result to your presenter.

            That way, your business logic can stay 100% in your interactor and your presenter can focus on how he will display that on screen.

            By the way, if your API needs a token for every call you should move it in an Interceptor so you do not have to deal with it at every call.



            Making synchronous calls to Cloud Firestore when running off the main thread
            Asked 2019-Feb-27 at 13:31

            I am building an app based off of the Android Clean Architecture Kotlin version (

            Using this architecture, each time you want to invoke a use case, a Kotlin coroutine is launched and the result is posted in the main thread. This is achieved by this code:



            Answered 2018-Jun-13 at 00:59

            That's is not the way how firebase works. Firebase is based on callback.

            I recommend architecture component's livedata.

            Please check the following example.

            here is a link:



            disjoint union in Kotlin to get access in Java
            Asked 2018-Nov-06 at 20:41

            I'm working in a mixed Java - Kotlin project. There's a class Either:

            In one of the Java classes I'm getting an instance of Either as a parameter in such a way:



            Answered 2018-Nov-06 at 20:41

            I... really wouldn't use this class for anything. It may just be for a specific purpose (given sample in package name). But either really needs a type parameter and left and right methods don't make sense.

            If you somehow have no choice, you should be able to call either like this:



            Clean architecture: Use CompositeDisposable in domain or presentation/app
            Asked 2018-Aug-07 at 04:34

            I just start learn and apply CleanArchitecture for my Android project.
            I see there are 2 great source for following here
            2) (

            Currently, the first source use the CompositeDisposable in domain (inside UseCase) and the second source use in presentation/app(Presenter/ViewModel)

            As my current understand, I see the benefit when we put CompositeDisposable in Presenter/ViewModel.

            • Easy to dispose (because if we CompositeDisposable in UseCase, for each UseCase we need to dispose call 1 time)
            • May easy to combine many UseCase (eg: UseCase1 execute then flatMap/zip... with UseCase2)

            I see the benefit when we put CompositeDisposable in UseCase

            • It separate RX from presentation

            I don't know if is there any other pros/cons of 2 approach. I never use CleanArchitecture for real project and I know when we follow any approach, it's quite hard to change to another approach.

            For me, currently I think I will choose: put CompositeDisposable in UseCase. What should I use? Is there any other approach?
            Any help or advice would be great appreciated.



            Answered 2018-Aug-07 at 04:34

            When it comes to clean architecture, I have been using 1) Android-CleanArchitecture for about a year now. And when it comes to disposing CompositeDisposable, I would do it in Presenter if I were you, because it is closely related to life-cycle of View and it controls data flow which CompositeDisposable in this case kind of belongs to.


            Convert 1) Android-CleanArchitecture from MVP to MVVM in Presentation layer with ViewModels and dispose your CompositeDisposable there. MVVM with Googles new ViewModel library eliminates headaches of managing life-cylce dependent objects yourself, which MVP in this CleanArchitecutre template fails to deliver.

            Hope this cleared things up a bit. Good Luck :)



            How to setup a project for Clean architecture in gradle?
            Asked 2018-Mar-11 at 09:49

            So I was going through clean architecture in android, really liked it how people even create separate projects for domain, data and presentation layer. I tried to create my own project for clean architecture but couldn't set up different projects for domain, data and presentation layers.

            How can I accomplish this kind of project architecture?



            Answered 2018-Mar-11 at 09:49

            Create one project as your main project of type Android Application Project. The separate layers can be added as library modules to your main project.

            Then you just need to add these library modules to your gradle file as dependencies. Android studio will usually take care of that. But just in case you needed to change the order of dependencies, you can do that in the gradle files of each module.



            Getting NullPointException when using Dagger2 and setRetainInstance(true);
            Asked 2018-Jan-26 at 10:45

            So I was following Clean Architecture to design my application. I have an Activity with a view pager which has two Fragment in it. Im injecting the PagerAdapter for this through Dagger.

            I understand that calling setRetainInstance(true) on a fragment prevents it from getting destroyed, and that getActivity() on such fragment may return a problem if the Activity is destroyed. I'm getting a NullPointException when trying to resume my activity after it has been on background and the activity has been (presumably) destroyed.

            So my question is

            • Is there a better way to accomplish what I'm trying to do?
            • Any resource someone can point me to?
            • Also uncertain why the Fragment and the Adapter is still active if the fragment has been destroyed. I get no memory leaks with LeakCanary.

            My activity has an Dagger Component MainActivityComponent which is injected as follows. And also extends HasComponent. For more info on this refer to HasComponent




            Answered 2018-Jan-26 at 10:45

            The problem occured when the application stays in the background for a while and a recently displayed activity is recycled by Android. Bringing back the application causes NullPointerException (NPE) as the activity’s component is called by the fragment before it is initialized (both fragment and activity are recreated at the same time).


            Introducing two lifecycle methods in BaseFragment class.

            1. onInjectView() — called to do an optional injection on onCreate(Bundle) and if an exception is thrown or false returned, it is called on onActivityCreated(Bundle) again. Within this method you can get the injection component and inject the view. Retrun true if the injection was succesfull, then it will not be called again.
            2. Based on returned value, the second method is called. The method is named onViewInjected(Bundle), as it is called only when the fragment has been injected and injected fields can be initialized.
            Base Fragment



            How to mock final class with Mockito 2 on Java Module in Android project?
            Asked 2018-Jan-05 at 12:00

            I have a Android Clean Architecture project write in Kotlin with 3 modules:

            • data (Android Library)
            • domaine (Java Library)
            • presentation (Android Application)

            The 3 modules each have unit tests written with junit. But with Kotlin every class is final by default. I quickly had the problem: How to mock a final class with mockito

            It's now possible with Mockito 2

            It can be done via the mockito extension mechanism by creating the file /mockito-extensions/org.mockito.plugins.MockMaker containing a single line:



            Answered 2017-Jul-10 at 10:26

            You can use the inline mocking method by default, by changing your Gradle dependency from the normal Mockito dependency:



            Android app clean architecture: Should data layer have its own model classes?
            Asked 2017-Dec-20 at 11:05

            What´s the best approach when developing an Android app and trying to follow clean architecture guidelines (but not extremely strict - cause that may be overkill for smaller projects).

            In my case, I am unsure which approach is the best (if there is a best one) regarding the data layer and if the data layer should operate on its own model classes or if it may operate directly on the domain layer models.

            Also, if the data layer should operate on its own model classes, should data sources like DB or API have their own models (like for an API using Retrofit and Gson a model class with Gson annotations) and then map to data layer models OR should the data layer model itself be the model returned by DB and API (this means the data layer model must be annotated for Gson being able to parse it in case of Retrofit and Gson).

            This is the case in this project:

            The following images should clarify the 3 approaches I mean:

            In Image 1 the DB and API return specific model classes. In the case of the API it may look like (using Retrofit and Gson):



            Answered 2017-Dec-20 at 11:05

            If I were you, I would go with the Image1 process. I think it is the job of your datasource to take whatever object is coming from your database or API or any endpoint you have and transform it into something easier to user in your repository.

            Between Image1 and Image2, I think it depend of what data you want to store and what is the object you want to store. You may or may not need an ArticleEntity depending of your business rules. And if you don't need it, you don't have to create one.

            But for some use case you may need to create that object to add some informations to your Article. For exemple, if you want to place in that a validity date or any other information that you will only use in your repository, you can go for Image2.



            Android library module does not compile when using classes from pure Kotlin module
            Asked 2017-Oct-04 at 13:10

            I have a project using this structure:, and I am trying to convert it to Kotlin.

            The domain module compiles just fine, but when I try compile the data module I get the following error:



            Answered 2017-Oct-04 at 13:10

            I finally found why it was not compiling: I had to call "rebuild project" rather than "make project" in order for Android Studio to take all the changes into account.



            Publish to specific Observer using PublishSubject
            Asked 2017-Sep-24 at 10:11

            I have a ViewPager with two pages namely Popular and All. What I'm trying to achieve is only push items that have popular tag true to Popular whereas push all items to All.

            Currently I have a single class which is used in the PagerAdapter and passing in the page type. How do I filter out PublishSubject so that each page only displays necessary items accordingly.

            Both my Observer are subscribed to a single PublishSubject, but I want to filter when emitting.

            Please comment if the question is unclear. I'll try my best to relay this problem. Also sorry if it has already been answered since I couldn't find anything relevant.

            The code I'm using is this based on this architecture in which I have a Firebase data store FirebaseSubscriptionDataStore which provides the PublishSubject. This is later subscribed to by SubscribeToSubscriptionUpdates in SubscriptionListPresenterImpl

            Thanks in advance.



            Answered 2017-Sep-24 at 10:11

            You can basically define two different methods to get Observable (or Flowable) from PublishSubject. First observable will emit all of the items and second one only popular ones:


            Community Discussions, Code Snippets contain sources that include Stack Exchange Network


            No vulnerabilities reported

            Install Android-CleanArchitecture

            You can download it from GitHub.
            You can use Android-CleanArchitecture like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the Android-CleanArchitecture component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer For Gradle installation, please refer .


            For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
          • HTTPS


          • CLI

            gh repo clone android10/Android-CleanArchitecture

          • sshUrl


          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link