Facebook SDK 3.1.2 for Unity - Trouble logging in on Android Devices
Asked Answered
N

2

3

I'm using the latest version of the Facebook SDK, version 3.1.2, for Unity. My problem is somewhat similar to this question. The differences being that my iOS builds work just fine. And my Android builds aren't getting null references. Instead, My android build will just not log in.

When I click my login button, it'll bring up the dialogue screen to give the app permission to access the basic stuff, public profile and friend list. Upon hitting the ok button, it'll return me to my app but fail the login. I found the AndroidFacebook class and noticed that OnLoginComplete function has a string message param where it should grab the user's id and access token from. So I put a debug message in there to see what was being returned. It turns out that although I press ok to give the app access to facebook, it's saying that the process was cancelled. {"cancelled":true} is the Json string being returned. I've doubled check my app settings in the facebook developer page and the Package name, class name and debug hash key all match what I have in the Unity Facebook settings. I've even tried with the Sandbox mode on and off.

Notation answered 18/9, 2013 at 14:40 Comment(1)
Just released a new SDK today that fixes a set of android issues: developers.facebook.com/docs/unity/downloads Let me know if you're still having problems. If you can stick an example project on github I'd be glad to take a lookReticular
A
3

It sounds like you don't have the android key hash set up correctly. In the Unity Editor, click the Facebook entry on the main menu bar, then click "Edit Settings". Find the item marked "Debug Android Key Hash" and copy the value to your clipboard.

Navigate to http://apps.facebook.com and find you app. Paste the key hash you took from the editor into the "Key Hashes" section of your apps native android setup. This page has a picture of how your setup should end up looking.

Ahasuerus answered 18/9, 2013 at 18:33 Comment(3)
I've done that already. I even ran the keytool just incase the one displayed in the settings was invalid. came up with the same key. In relation to this though; We haven't created an app for the play store yet. so our Package Name is made up. Could that have anything to do with it?Notation
Does the package name you have in unity match the one you have on the facebook app setup page?Ahasuerus
Yes it does. I take it that if they match then it doesn't matter?Notation
S
2

Does your main activity extend the FBUnityPlayerActivity class?

We're running into the same problem, and tried the same fixes - just now noticing this as a warning in the editor logs.

Spicule answered 18/9, 2013 at 22:10 Comment(2)
com.facebook.unity.FBUnityPlayerActivity why yes, it does. although I'm not getting any warning. hmmNotation
I actually meant that in the opposite manner - ours wasn't extending that class, but I wasn't sure if that was the crux of the problem or not - thanks!Spicule

© 2022 - 2024 — McMap. All rights reserved.