Facebook Account Kit Collision with Google play services gradle
Asked Answered
A

4

10

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.

Aelber answered 4/11, 2017 at 10:45 Comment(1)
I have faced this problem before with another library (not Picasso). It happens because Facebook Account Kit SDK is using an older version of some libraries than you are. I have couple of suggestions that can help you fix the problem. But for me to fully understand, can you post the build.gradle(app) of your app.Dicotyledon
A
2

For Unable to get provider RuntimeException exception it seems that, Application is not initialized first, Content Providers are initialized before it. And in Facebook account kit SDK's code it was trying to get my application context.

Now the problem was, I did implement method getApplicationContext() in application class that is getting application shared variable but that variable was setting globally and Facebook Account Kit sdk code getting Null application context.

Solution : setting shared variable in onCreate method instead of setting globally it resolved the problem of Unable to get provider.

And For Mixing issue, Account Kit SDK use 11.0.1 version for play services gradle and in my project I am having 11.0.4 that is actually not the issue because on compile time gradle takes latest gradle but In my project I am not referring below gradle which Facebook Account Kit SDK is using.

compile 'com.google.android.gms:play-services-auth-api-phone:11.0.1'

Solution : I have added above gradle with version 11.0.4 and the mixing gradle issue has been resolved.

compile 'com.google.android.gms:play-services-auth-api-phone:11.0.4'

And as suggested by @astryk if I exclude play-services-auth-api-phone module then gradle mixing error is not showing but it is not including that module becasue in AccountKitActivity on next button click my application crashes as

Crash Report Thread:main Exception:java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/auth/api/phone/SmsRetriever;
at com.facebook.accountkit.internal.PhoneLoginController.createSmsToken(PhoneLoginController.java:250)
at com.facebook.accountkit.internal.PhoneLoginController.logIn(PhoneLoginController.java:188)
at com.facebook.accountkit.internal.LoginManager.logInWithPhoneNumber(LoginManager.java:372)
at com.facebook.accountkit.internal.AccountKitController.logInWithPhoneNumber(AccountKitController.java:631)
at com.facebook.accountkit.ui.PhoneLoginFlowManager.logInWithPhoneNumber(PhoneLoginFlowManager.java:57)
at com.facebook.accountkit.ui.ActivityPhoneHandler.onPhoneLoginComplete(ActivityPhoneHandler.java:189)
at com.facebook.accountkit.ui.AccountKitActivity$1.onReceive(AccountKitActivity.java:176)
at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
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.ClassNotFoundException: Didn't find class "com.google.android.gms.auth.api.phone.SmsRetriever" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappList item -1/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 16 more
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.auth.api.phone.SmsRetriever
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available`
Aelber answered 13/11, 2017 at 5:48 Comment(0)
S
11

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.

Shattuck answered 10/11, 2017 at 22:16 Comment(2)
This sounds most appropriateDicotyledon
@Shattuck after implement your solution mixing issue resolved, but it crash on AccountKit activity. Please see my answer.Aelber
C
3

Possibly the conflict of libraries can be the reason. See dependencies here; https://mvnrepository.com/artifact/com.facebook.android/account-kit-sdk/4.27.0

See if you could submit an issue with the facebook to update it.

Or if you need facebook for authentication only, you can use Facebook Android Sdk

enter image description here

Cahoon answered 7/11, 2017 at 13:32 Comment(1)
I need Facebook Account Kit for Mobile number Login and also Please note that I am already using FB Login via Facebook Android SDK.Aelber
W
2

What feature/service from firebase r u using , can u pls share the snippet of ur gradle dependencies for the same to better understand the problem here?

Wagonlit answered 7/11, 2017 at 9:22 Comment(10)
I am using firebase messaging as compile 'com.google.firebase:firebase-messaging:11.0.4' Aelber
and if i may ask, have u already tried with the latest version com.google.firebase:firebase-messaging:11.6.0 ? and just one more point: pls have a look on these posts in-case u haven't earlier: groups.google.com/forum/… atimothee.github.io/blog/2016/09/17/…Wagonlit
I did test with version 11.4.0 also with no success and 11.6.0 is yesterday's build release.Aelber
Pls ignore the bad formatting in my earlier comment & have a look on these posts in-case u haven't earlier: [groups.google.com/forum/… [atimothee.github.io/blog/2016/09/17/…Wagonlit
Thanks to reply............did check with Urls.As discussed with first I already have setup App in Facebook and in second it is not using Account kit gradle.Aelber
If I am getting it correclty form your comment by "first: u mean the first link & same as for "second", then the Second link has a link to its github src(github.com/atimothee/accountkit-firebase-auth-android/blob/…) which has added Account kit dependency along with firbase-authWagonlit
compile 'com.google.android.gms:play-services-maps:11.6.0' compile 'com.google.android.gms:play-services-location:11.6.0' compile 'com.google.android.gms:play-services-places:11.6.0' compile 'com.google.android.gms:play-services-auth:11.6.0' compile 'com.facebook.android:account-kit-sdk:4.+' compile 'com.google.firebase:firebase-core:11.6.0' compile 'com.google.firebase:firebase-messaging:11.6.0' This is the snippet from my gradle file & it just syncs fine, without any warning like " as mixing versions can lead to runtime crashes"Wagonlit
Thanks to reply...let me check.Aelber
I tried integrating Facebook Account kit in my App today along with SMS login, below is the gradle file snippet i used: compile 'com.facebook.android:account-kit-sdk:4.+' compile 'com.google.firebase:firebase-core:11.6.0' compile 'com.google.firebase:firebase-messaging:11.6.0' compile 'com.google.firebase:firebase-database:11.6.0' I dindn't faced any such issue/conflicts with dependencies & app ran just fine. Kindly please share the elaborated code sample to check it in detail/further for the specific issue u r facing. And Fyi..My IDE is AS 3.0 & device is Android 7.0Wagonlit
Thanks to reply please check code scontent.fbom8-1.fna.fbcdn.net/v/t39.2087-6/… and Please find changes in ctdev-npe branch.Aelber
A
2

For Unable to get provider RuntimeException exception it seems that, Application is not initialized first, Content Providers are initialized before it. And in Facebook account kit SDK's code it was trying to get my application context.

Now the problem was, I did implement method getApplicationContext() in application class that is getting application shared variable but that variable was setting globally and Facebook Account Kit sdk code getting Null application context.

Solution : setting shared variable in onCreate method instead of setting globally it resolved the problem of Unable to get provider.

And For Mixing issue, Account Kit SDK use 11.0.1 version for play services gradle and in my project I am having 11.0.4 that is actually not the issue because on compile time gradle takes latest gradle but In my project I am not referring below gradle which Facebook Account Kit SDK is using.

compile 'com.google.android.gms:play-services-auth-api-phone:11.0.1'

Solution : I have added above gradle with version 11.0.4 and the mixing gradle issue has been resolved.

compile 'com.google.android.gms:play-services-auth-api-phone:11.0.4'

And as suggested by @astryk if I exclude play-services-auth-api-phone module then gradle mixing error is not showing but it is not including that module becasue in AccountKitActivity on next button click my application crashes as

Crash Report Thread:main Exception:java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/auth/api/phone/SmsRetriever;
at com.facebook.accountkit.internal.PhoneLoginController.createSmsToken(PhoneLoginController.java:250)
at com.facebook.accountkit.internal.PhoneLoginController.logIn(PhoneLoginController.java:188)
at com.facebook.accountkit.internal.LoginManager.logInWithPhoneNumber(LoginManager.java:372)
at com.facebook.accountkit.internal.AccountKitController.logInWithPhoneNumber(AccountKitController.java:631)
at com.facebook.accountkit.ui.PhoneLoginFlowManager.logInWithPhoneNumber(PhoneLoginFlowManager.java:57)
at com.facebook.accountkit.ui.ActivityPhoneHandler.onPhoneLoginComplete(ActivityPhoneHandler.java:189)
at com.facebook.accountkit.ui.AccountKitActivity$1.onReceive(AccountKitActivity.java:176)
at android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297)
at android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46)
at android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116)
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.ClassNotFoundException: Didn't find class "com.google.android.gms.auth.api.phone.SmsRetriever" on path: DexPathList[[zip file "/data/app/com.myapp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.myappList item -1/lib/arm64, /vendor/lib64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
... 16 more
Suppressed: java.lang.ClassNotFoundException: com.google.android.gms.auth.api.phone.SmsRetriever
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 17 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available`
Aelber answered 13/11, 2017 at 5:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.