Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook Account Kit Collision with Google play services gradle

After configuring account kit sdk as

  compile 'com.facebook.android:account-kit-sdk:4.+'

and gradle sync it conflict with com.google.android.gms gradle as mixing versions can lead to runtime crashes and my app crash as

Firebase API initialization failure. java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at com.google.firebase.FirebaseApp.zza(Unknown Source) at ...

the above error is due to mixing google play services gradle (I think Google play services gradle may be used by Facebook Account Kit SDK) because I have same version for all Google play services gradles.

And one more crash is coming from Facebook Account Kit SDK side as

 java.lang.RuntimeException: Unable to get provider com.facebook.accountkit.internal.AccountKitInitProvider: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
                                                       at android.app.ActivityThread.installProvider(ActivityThread.java:5260)
                                                       at android.app.ActivityThread.installContentProviders(ActivityThread.java:4808)
                                                       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4748)
                                                       at android.app.ActivityThread.access$1700(ActivityThread.java:153)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:154)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5529)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference
                                                       at com.facebook.accountkit.internal.Initializer.initialize(Initializer.java:99)
                                                       at com.facebook.accountkit.internal.AccountKitController.initialize(AccountKitController.java:592)
                                                       at com.facebook.accountkit.internal.AccountKitInitProvider.onCreate(AccountKitInitProvider.java:31)
                                                       at android.content.ContentProvider.attachInfo(ContentProvider.java:1758)
                                                       at android.content.ContentProvider.attachInfo(ContentProvider.java:1733)
                                                       at android.app.ActivityThread.installProvider(ActivityThread.java:5257)
                                                       at android.app.ActivityThread.installContentProviders(ActivityThread.java:4808) 
                                                       at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4748) 
                                                       at android.app.ActivityThread.access$1700(ActivityThread.java:153) 
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1436) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                       at android.os.Looper.loop(Looper.java:154) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:5529) 
                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629) 

But after removing

  compile 'com.facebook.android:account-kit-sdk:4.+'

my app working without any issue. But to integrate Facebook Account Kit in my app I have to include above gradle which conflict with google play services.

Totally disappointed, please help.


After upgrading Firebase Gradle as

compile 'com.google.firebase:firebase-messaging:11.6.0'

its not colliding but still gives above RuntimeException from Account Kit SDK.

like image 863
Giru Bhai Avatar asked Nov 04 '17 10:11

Giru Bhai


1 Answers

To fix this you can do something like the following

compile ('com.facebook.android:account-kit-sdk:4.27.0') {
        exclude group: 'com.google.android.gms', module: 'play-services-auth-api-phone'
        exclude group: 'com.google.android.gms', module: 'play-services-auth'
    }
    compile 'com.google.android.gms:play-services-auth:11.6.0'
    compile 'com.google.firebase:firebase-messaging:11.6.0'

That would remove the stale support gms library from Facebook's SDK and then swap in the same version of the lib that Firebase is using.

like image 87
astryk Avatar answered Sep 19 '22 05:09

astryk