Skip to main content
1 of 3

Clean Architecture : Google/Facebook Login and data layer

I'm trying to find a way around the integration of Google and Facebook login for an Android application using the Clean Architecture.

My application has 3 layers :

  • presentation : contains all my UI (Activity, Fragment, Custom Views), the Presenters and the ViewModels
  • domain : contains the business models, Use Cases, and repository interfaces
  • data : contains all the libraries (retrofit, databases, etc) and repository implementations

I would like to isolate the login specific SDKs in my data layer (which is a separate module in Android Studio).

The issue I have for this particular use case (Google login for example) is that the SDK need to talk directly to my Activity (presentation layer). Once I have built a specific object, I need to call startActivityForResult from an Activity, and I receive a callback in the onActivityResult method of my launching activity, containing the login informations.

These 2 things make an obligation to :

  • either keep the Google/Facebook SDK dependencies in the presentation layer. BUT this violates the clean architecture principle, I would like to keep these dependencies in my data layer
  • or add a call which will go through all my layers (presentation, domain and data) to give back the login informations from the onActivityResult method. BUT this means that I would modify my domain contract because of a particular login SDK

None of this seems OK. Do you know a proper way to handle this use case ?