Search Unity

Issues initializing Facebook SDK 7.1.0 on Android

Discussion in 'Android' started by vincerp, Oct 10, 2015.

  1. vincerp

    vincerp

    Joined:
    Jan 24, 2015
    Posts:
    9
    I'm currently having a ton of issues connecting to Facebook through Android using their new SDK version. We've recently updated from the previous one to be able to do WebGL builds, but now the Android builds are completely broken.
    FB.Init does not properly initializes the SDK, even though I've assured that all of the values from Facebook settings are the same as the ones in my app settings page.

    FB.IsInitialized is still false after init. I tried verifying if it was still possible to do anything, but calling FB.ActivateApp would just crash the game, and trying to Login (with either Read or Publish permissions) would freeze the screen.

    Anyone had anything similar going on or suggests any possible fix for this?

    EDIT: Additional info:
    Tested on both a OnePlus One and a Nexus 7, latest android version installed on both. Tried unninstalling the Facebook app as well to see if it affected anything, but no changes.
     
    Last edited: Oct 10, 2015
    mobra likes this.
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,346
    Did you use the previous FB SDK before upgrading to the latest one (7.1.0) ?
    If you rollback to the previous one, does everything work as expected ?

    Other things to look out for:

    1. Are all your settings properly configured (both in Unity - Facebook settings and in Facebook itself, where you set all the properties for your game).
    2. Try building a development build. Monitor all logs in logcat to see if you're getting any errors back from the FB SDK.
     
  3. vincerp

    vincerp

    Joined:
    Jan 24, 2015
    Posts:
    9
    Yeah, we've been using the latest one until yesterday. Rolled it back and I don't seem to have any issue with Facebook now.

    I double- and triple- checked all the information from both Unity and the Facebook page and I'm pretty sure they matched perfectly.

    Unfortunately, I overwrote my logcat from my tests last night. I'll go back to that branch, see if I find anything suspicious and post it here later.
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,346
    Post your logs from logcat if possible, maybe we can spot something in there :)
     
  5. vincerp

    vincerp

    Joined:
    Jan 24, 2015
    Posts:
    9
    There you go:

    http://pastebin.com/Z2vHTZKx

    At the end, I'm crashing the game because I call FB.ActivateApp even though it doesn't initialize.

    This one also happens at the end of initialization:
    I/Unity (10741): AndroidJavaException: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/FacebookActivity;

    Not sure what to do about it, though.
     
  6. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,346
    It looks like you're missing the com.facebook.FacebookActivity class from your game.

    Are you sure it is included? i am not sure how it is delivered in 7.1.0, is there a .JAR or .AAR file that is included with the SDK ?

    Can you list what you have in your Assets/Plugins/Android folder to see what it contains ?

    You can cd into Plugins/Android from a command prompt (on windows) and then hit dir /w > File.txt
    This will save a file with all contents of your folder. Then share it on pastebin as well.
     
  7. vincerp

    vincerp

    Joined:
    Jan 24, 2015
    Posts:
    9
    There are two files at Asseets/Plugins/Android/lib:

    facebook-android-sdk-4.6.0.aar
    facebook-android-wrapper-release.aar

    ...plus bolts and other libraries in there. I have some other duplicated libraries from Google Play services that come from the different plugins that I'm using, but I've made sure to disable all of them when compiling.

    I've just opened the first .aar with WinRAR and checked the jar inside and com.facebook.FacebookActivity is at least in there. Could it maybe be something about Java not compiling things properly? I'm currently using jdk1.7.0_75

    Additionally, I've seen that FB.Init wrongly sets the Initialized boolean only after it calls the callback, but changing it didn't make any difference.
     
  8. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,346
    Did you follow the integration guide at: https://developers.facebook.com/docs/unity/gettingstarted

    the last thing i can think of is that the Activity (or activities) for Facebook are not declared in your AndroidManifest.xml

    This manifest is generated (or patched, if it's already there) after you open the Facebook settings dialog (Top "Facebook" menu -> Edit Settings). There's a button there "Regenerate Android Manifest" that should prep up your AndroidManifest file with all the needed activities.

    Did you perform that step ? do you have a valid AndroidManifest.xml under Plugins/Android ?
     
  9. vincerp

    vincerp

    Joined:
    Jan 24, 2015
    Posts:
    9
    Yep, done that a bunch of times already, and verified that I had the manifesto with the FB stuff. Still nothing.
     
    liortal likes this.
  10. vincerp

    vincerp

    Joined:
    Jan 24, 2015
    Posts:
    9
    Just to put the closure to this issue here.

    Everything was solved on the 13th when Facebook released the new version of their SDK. I simply got rid of all references that I had from the previous version and added the new one. I had no problems with Android since then, so I imagine that whatever issue I had, it was solved with their latest release.
     
  11. Jakhongir

    Jakhongir

    Joined:
    May 12, 2015
    Posts:
    37
    My game crashes on ios when initializing the fb sdk.