Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Imawizrd · Sep 26, 2013 at 07:10 AM · androidfacebooklogin

Facebook SDK v4.2.4 - Android - Login not working

Hi Guys,

I've been stuck on this one for most of the day.

I'm trying to run the example scene that comes with the Facebook SDK v4.2.4 unity package. I have it working fine on iOS except Android is giving me trouble.

When I launch the application I press FB.Init and it loads successfully. When I press the Login button the screen goes black for less than a second and returns back to the scene and the other buttons (except Publish Install) are still greyed out.

I believe my problem is related to my Key Hash. At first my key has wasn't appearing in the FacebookSettings panel in Unity. So I downloaded an OpenSSL zip and moved it into my jdk bin folder (C:\Program Files\Java\jdk1.7.0_40\bin\openssl.exe) I then manually got a key from the cmd. Then I noticed at a later point the FacebookSettings panel was showing me the same key hash I got from the cmd.

Maybe I stuffed up retrieving the correct key hash?

What was the correct way to retrieve my key hash?

Currently my Facebook app settings match the details in Unity. (package name, class name, key hash). I am doing all of my Android testing on a device and not an emulator.

Apologies for writing another "Login not working" question. I read through the other questions and felt they all had different issues to mine as they were able to see the login screen.


Note, if you're on a Mac...

the "Rafael solution" is the only solution:

http://answers.unity3d.com/questions/609810/using-facebook-api-with-android-says-login-is-canc.html

(it is also (by far) the easiest and simplest solution if you are not on a Mac)

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Imawizrd · May 05, 2014 at 06:17 AM 0
Share

I stopped following this question after my problem was resolved some how last year. But after reading the discussion today I figured @brian_jew provided an answer within the update of his answer.

We found out that sometimes the older version of openssl may not generate the correct keyhash. You can either update your openssl or check out this stackoverflow answer here for an alternate solution to getting a proper keyhash

I guess you still need to mess around with the keyhash but it still answers/resolves the problem for the original question.

avatar image Fattie · May 05, 2014 at 06:26 AM 1
Share

Hi @imawizard ... thanks for that. One question, did you notice that when you update the key hashes on developers.facebook -- does that propafate instantly? Or do you have to wait? IT adds more confusion!

Answer - we did some experimentation on that; in fact changes to the "$$anonymous$$ey Hashes" on developers.facebook do propagate instantly. It's 100% certain. So that's one issue off the table at least. Cheers all


Again, the solution is this:

ttp://answers.unity3d.com/questions/609810/using-facebook-api-with-android-says-login-is-canc.html

that even works if you are on $$anonymous$$ac

avatar image BlackPanda · Oct 29, 2014 at 07:31 AM 0
Share

yes Rafael's solution worked for me!

11 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by brian_jew · Sep 26, 2013 at 05:36 PM

Hey no worries. Android development is tough. As one of the engineers that built the SDK, we're trying to make it easier for people. It sounds like you already did this:

Instructions

Are you using the default package name: com.Company.ProductName ? There's a known issue that somethings don't work correctly with that. You can edit the Android build settings to change the Bundle Identifier (we called it "Package Name" here to match the facebook developer settings). We'll also look into it on our end.

Some other answers that might help us if the above doesn't help: -Which version of Android do you have? -Is the Facebook App installed? -Do you have adb setup to monitor the logs from Android? A log dump of adb log right before and after the login happened would help. (Set your unity build to do a "Development Build" for more debug stuff to log.)

You can send all that info to: unity-sdk@fb.com and we'll follow up.

UPDATE: We found out that sometimes the older version of openssl may not generate the correct keyhash. You can either update your openssl or check out this stackoverflow answer here for an alternate solution to getting a proper keyhash: http://stackoverflow.com/questions/19051361/facebook-unity-sdk-on-android-login-fails-when-fb-app-installed


untitled.png (12.7 kB)
Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Imawizrd · Oct 03, 2013 at 12:02 AM 0
Share

A couple of days later I was about to send my project to the Facebook guys. Though before I send it I did a last test and it started working. I didn't make any changes at all. So it could of been their back-end or something. They didn't have any suggestions as to why it started working again.

One thing they did mention in an email was:

"Will login work on your android if you uninstall the Facebook app? If that works it is an issue we're digging into this week."

I never had the Facebook app on my device, though that suggestion may work for you.

avatar image Caieu · Oct 03, 2013 at 01:29 AM 0
Share

i've got the same error, and when i uninstalled the Facebook app, i was able to get the login working.

avatar image nebjezus · Oct 03, 2013 at 01:36 AM 0
Share

I have uninstalled the Facebook app on my device, and while the logs appear to be showing that the login is successfully (i.e. the access token is being returned), it doesn't seem to be firing the callback.

This would make me think that there is an error in the code logic, but we have built this application for iPhone and the logic has worked just fine.

avatar image Hatt_001 · Dec 17, 2013 at 04:34 PM 0
Share

Sorry to ask in this, but has that problem been solved, I have the same problem, I Uninstall the Facebook App and it works like a charm

avatar image kazerman55 · Feb 21, 2014 at 08:29 AM 0
Share

Yeah same for me, but that's a problem. How can I make this work if someone already has the Facebook app on their phone?

Show more comments
avatar image
3

Answer by rakib_evatix · Feb 26, 2014 at 07:33 AM

I was having same problem, I tried a lot of things like changing openssl or generating release keystore properly, and many other stuffs but what really solved my problem is, my game is in 'landscape' mode and com.facebook.LoginActivity was in 'portrait' mode. I manually changed it to 'landscape' in AndroidManifest.xml located inside Assets\\Plugins\\Android folder which solved the problem for me. Hope that helps. alt text

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Starkadder · Mar 11, 2014 at 10:42 AM 0
Share

I've been stuck on this one for hours, and this is the thing that finally worked for me. Thanks so much!

avatar image rakib_evatix · Mar 16, 2014 at 07:43 PM 0
Share

No problem. Later I found out that you can just remove 'android:screenOrientation' portion altogether, so com.facebook.LoginActivity does not require any orientation. This the cleaner way I think. Anyway, glad that it helped you :)

avatar image Starkadder · Mar 18, 2014 at 01:19 PM 0
Share

That does sound better. Again, thanks so much for sharing your findings.

avatar image
2

Answer by urhire@yahoo.com · Aug 12, 2014 at 07:39 AM

The Best and the easiest solution ever!!!

I have done a tricky way to achieve that which is more simpler than any solution.

  1. Let your game app stay with the generated key hash in facebook edit setting. Don't worry about the correct key hash.

  2. Make sure you have wrong android hash key pasted on facebook app setting in your developer account.

  3. Build your game and try log in with your Fb developer account.

  4. Now As soon as your game app doesn't find the same hash key then facebook app will pop up and taaaddaaaaaa. Here you go with correct key hash, just note down the hash key and now paste into your facebook app setting in your developer account

Worked like a charm!!!

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Imawizrd · Sep 23, 2014 at 12:43 AM 0
Share

I use this method now as well. Very easy.

avatar image lui69 · Jan 23, 2019 at 04:42 AM 0
Share

were do you find the correct hash key in the Editor Log?

avatar image
0

Answer by vivalavladislav · Jan 10, 2014 at 02:29 PM

I've experienced the same problem. Just upgrade your facebook sdk to 4.3.6 and everything will be okay :)

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by kombdakhiladi · Feb 04, 2014 at 10:19 AM

I had the same problem. It worked once I uninstalled the Facebook App from my device. I checked it by displaying the FB.UserId,FB.AccessToken - which were no more empty strings!

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SkaiCloud · Mar 16, 2014 at 06:04 AM 0
Share

Yes I confirm that by uninstalling facebook app did indeed allow my app to grab facebook information. This is a good temporally fix but unfortunately it is best for debug purpose.

  • 1
  • 2
  • 3
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

33 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Facebook SDK login issue with facebook api 0 Answers

How do I correctly install the Facebook SDK plugin? 1 Answer

Facebook Login " Invalid App Id : 0 " 0 Answers

Why the feed stories of my facebook game attempt to open the canvas instead of launch the Android/iOS mobile application? 1 Answer

Openssl not found in unity sdk for facebook 6 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges