Resolving transitive dependencies while adding AccountKit alongside Firebase

Rishabh Maurya
MindOrks
Published in
1 min readAug 21, 2018

Today, I was integrating FB account kit in my app. It already had various Firebase dependency included viz. auth,database,cloud messaging and et al. Going by what was mentioned in FB developer documentation, I added the dependency for account kit in app’s build.gradle module.

implementation ('com.facebook.android:account-kit-sdk:4+')

After which, I encountered the following error at runtime:

 Failed resolution of: Lcom/google/android/gms/common/api/Api$zzf; at com.google.android.gms.auth.api.Auth.<clinit>(Unknown Source) at com.facebook.accountkit.ui.AccountKitActivity.onCreate

I tried changing the version code of Firebase dependencies to same version code but it was of no use. After scouring the Stack Overflow for some time, I came across an excellent answer by Astryk . What formed the underpinning of the aforementioned error was the conflict arising due to difference in the versions of 'play-services-auth in Firebase and AccountKit library.

As suggested by Astryk, one need to exclude these modules so that AccountKit can employ the fresh modules from Firebase in order to work properly. Here, exclude rule of gradle comes to the rescue. It has two attributes- group and module.

implementation ('com.facebook.android:account-kit-sdk:4+')
{
exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone'
exclude group: 'com.google.android.gms', module: 'play-services-auth'
}

Thanks for reading !

--

--