Facebook Sample App

I’ve been having some issues getting the sample facebook app (/Networking/Facebook) working on a physical android device

I’ve followed all the guides and updated the build.settings and main.lua to include the appID.  I generated the key hashes and filled in all the appropriate information on the facebook developer site.

Looks like most people struggled with the key hash generation.  I’ve read that the error should popup via logcat in adb.  but I don’t see any message come up.  

I/ActivityManager( 145): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=jaman.facebooktest/com.ansca.corona.CoronaActivity} from pid 378 I/ActivityManager( 145): Displayed jaman.facebooktest/com.ansca.corona.CoronaActivity: +99ms V/Corona (32289): \< Class.forName: network.LuaLoader V/Corona (32289): Loading via reflection: network.LuaLoader W/InputManagerService( 145): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@41203db8 (uid=10035 pid=378) D/

I also tried to write a small app with a few lines:

local function fbListener( event ) print("facebook listener triggered") end facebook.login( fbAppID, fbListener, { "publish\_stream" } )

I don’t see any print statements in the log file indicating the listener was called

I’m using build 1076.  When the sample app loads there is no prompt for login.  The screen just shows a big block at the bottom of the page saying not logged in.  none of the buttons do anything when clicked.

Any pointers?

Hi @gjaman,

Of the guides you followed, did it include this one?

http://docs.coronalabs.com/guide/social/setupFacebook/index.html

Under the “Native Android App” subsection, see if that’s the same step(s) you followed in your configuration.

Regards,

Brent Sorrentino

@gjaman, I was about to mention the same (i.e., making sure you followed the latest guide).

And… even though I’m pretty sure it’s not the cause of your issue, “publish_stream” is deprecated by Facebook, and it’s probably better if you change it to “publish_actions”.

Naomi

I’ve followed those instructions, but i’m still missing something.  I tried downgrading to an old public release and the problem persisted.  My gut is telling me it must be the hash key.  I don’t have the ~/.android/debug.keystore, so I was using keytool against the debug.keystore in the /CoronaSDK/Resource Library/Android/

 

To build hash key I did:

$cd /Applications/CoronaSDK/Resource\ Library/Android/ $ keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64 \<\< password: android \>\> output key that it put into key hashes&nbsp; &nbsp;

 

My build setting in Corona:

Application name: Facebook Version code: 1 Version name: 1 Package name: jaman.facebooktest Min sdk 2.2 Target app store: google play Teystore : debug.keystore (/Applications/CoronaSDK/Resource Lirary/Android/Debug.keystore) Keyalias: androiddebugkey &nbsp;

 

facebook developer portal setup:

package name: jaman.facebooktest class name:&nbsp;com.ansca.corona.CoronaActivity key hashes: \<\<generated from keytool\>\> facebook login: enabled deep linking: enabled &nbsp;

For android, The only other changes in code are updating the appID in code and in the build.settings.

I also changed publish_stream to publish_actions just in case.  Do I need to do anything with open graph  or permissions to get the login screen to work?  And I using the right keystore?

It sounds like the problem is you using the debug.keystore.  You won’t be able to release your app using debug.keystore, so you might as well generate a keystore for your project, and your problem will probably go away.

Naomi

generated a keystore:

keytool -genkey -v -keystore jaman.keystore -alias jamanstore -keyalg RSA -keysize 2048 -validity 10000

and then generated the hash

keytool -exportcert -alias jamanstore -keystore jaman.keystore | openssl sha1 -binary | openssl base64

still no go.   Anyone have a working .apk of the facebook demo app they can share so I can verify my tablet is capable of running this?  My head is starting to hurt from banging it on the table :slight_smile:

Not sure if this is the cause of all your troubles, but here’s how I create keystore:

keytool -exportcert -alias myappalias -keystore myapp.keystore | openssl sha1 -binary | openssl base64

It looks a bit different from yours…

Naomi

Thanks Naomi - it looks like the command you posted is to generate the hash key vs generating the keystore ?

I also tried inserting a fake hash key in the facebook developer portal hoping the debug log (adb logcat) would provide an accurate one.  However, that didn’t work.

I compiled the example facebook app (http://jaman.ca/Facebook.apk)…  does anyone mind testing this and seeing if the login comes up?  

Thanks!

Ah, sorry, @gjaman.  

Oddly, I didn’t make a note of how I generated keystore or hash key (even though I just recently created one.)  So I thought I’d better figure out how I worked this one out.  Looking through my bookmark folder, I found this one for hash key.  I think it’s what I followed to get it done right without too much trouble:

http://forums.coronalabs.com/topic/19542-solved-facebook-and-android-key-hash/

And for keystore, I think I must have looked at this one (see Signing for Release Build section):

http://docs.coronalabs.com/guide/distribution/androidBuild/index.html#signing

Naomi

Edit:  Okay, I made a detailed note so that I won’t have to look for this again when I need another keystore.  And here’s how I get mine generated:

  1.  Launch Terminal.app  (I’m on Mac.)

  2.  Type the following and hit enter:

keytool -genkey -v -keystore mygame.keystore -alias mygamealias -keyalg RSA -keysize 2048 -validity 999999

Note:  for some reason, I don’t need to use sudo command at all

  1.  It asks me to enter keystore password, and then re-enter new password  (so I created password and made a note of it.)

  2.  Answer whole list of questions, including my name, my organization, my location.

  3.  Terminal spits out a list of my answers and asked if it’s correct.

  4.  Type yes and hit enter

  5.  It asks for keystore password for mygamealias (and tells me to RETURN if same as keystore password), so simply hit enter.

  6.  It will began storing mygame.keystore 

  7.  Done.  (I can find the keystore using file finder search.)

Looks like i’m doing the same thing as you.

I would have thought an error message would appear in the log if the hash key was wrong. I"m seeing no errors.  I’m going to try hunt down another android device to test on.

I also tested with and without the facebook app installed.  The steps to getting this setup are pretty simple, so not sure why it isn’t working for me.

That is really strange.  I have no idea why it isn’t working for you.  If I were in your position, I’d go over the FB dev portal in detail and make sure all is correctly set up (I’d also reference this guide to make sure I’m not missing anything – http://docs.coronalabs.com/daily/guide/social/setupFacebook/index.html)  When I’m 100% sure all is properly in place (and if it’s still not working), I’d uninstall the app, generate a new APK, reinstall, and see if it works.  If not, I’d try another android device just in case…

Good luck.

Naomi

Hi @gjaman,

Of the guides you followed, did it include this one?

http://docs.coronalabs.com/guide/social/setupFacebook/index.html

Under the “Native Android App” subsection, see if that’s the same step(s) you followed in your configuration.

Regards,

Brent Sorrentino

@gjaman, I was about to mention the same (i.e., making sure you followed the latest guide).

And… even though I’m pretty sure it’s not the cause of your issue, “publish_stream” is deprecated by Facebook, and it’s probably better if you change it to “publish_actions”.

Naomi

I’ve followed those instructions, but i’m still missing something.  I tried downgrading to an old public release and the problem persisted.  My gut is telling me it must be the hash key.  I don’t have the ~/.android/debug.keystore, so I was using keytool against the debug.keystore in the /CoronaSDK/Resource Library/Android/

 

To build hash key I did:

$cd /Applications/CoronaSDK/Resource\ Library/Android/ $ keytool -exportcert -alias androiddebugkey -keystore debug.keystore | openssl sha1 -binary | openssl base64 \<\< password: android \>\> output key that it put into key hashes&nbsp; &nbsp;

 

My build setting in Corona:

Application name: Facebook Version code: 1 Version name: 1 Package name: jaman.facebooktest Min sdk 2.2 Target app store: google play Teystore : debug.keystore (/Applications/CoronaSDK/Resource Lirary/Android/Debug.keystore) Keyalias: androiddebugkey &nbsp;

 

facebook developer portal setup:

package name: jaman.facebooktest class name:&nbsp;com.ansca.corona.CoronaActivity key hashes: \<\<generated from keytool\>\> facebook login: enabled deep linking: enabled &nbsp;

For android, The only other changes in code are updating the appID in code and in the build.settings.

I also changed publish_stream to publish_actions just in case.  Do I need to do anything with open graph  or permissions to get the login screen to work?  And I using the right keystore?

It sounds like the problem is you using the debug.keystore.  You won’t be able to release your app using debug.keystore, so you might as well generate a keystore for your project, and your problem will probably go away.

Naomi

generated a keystore:

keytool -genkey -v -keystore jaman.keystore -alias jamanstore -keyalg RSA -keysize 2048 -validity 10000

and then generated the hash

keytool -exportcert -alias jamanstore -keystore jaman.keystore | openssl sha1 -binary | openssl base64

still no go.   Anyone have a working .apk of the facebook demo app they can share so I can verify my tablet is capable of running this?  My head is starting to hurt from banging it on the table :slight_smile:

Not sure if this is the cause of all your troubles, but here’s how I create keystore:

keytool -exportcert -alias myappalias -keystore myapp.keystore | openssl sha1 -binary | openssl base64

It looks a bit different from yours…

Naomi

Thanks Naomi - it looks like the command you posted is to generate the hash key vs generating the keystore ?

I also tried inserting a fake hash key in the facebook developer portal hoping the debug log (adb logcat) would provide an accurate one.  However, that didn’t work.

I compiled the example facebook app (http://jaman.ca/Facebook.apk)…  does anyone mind testing this and seeing if the login comes up?  

Thanks!

Ah, sorry, @gjaman.  

Oddly, I didn’t make a note of how I generated keystore or hash key (even though I just recently created one.)  So I thought I’d better figure out how I worked this one out.  Looking through my bookmark folder, I found this one for hash key.  I think it’s what I followed to get it done right without too much trouble:

http://forums.coronalabs.com/topic/19542-solved-facebook-and-android-key-hash/

And for keystore, I think I must have looked at this one (see Signing for Release Build section):

http://docs.coronalabs.com/guide/distribution/androidBuild/index.html#signing

Naomi

Edit:  Okay, I made a detailed note so that I won’t have to look for this again when I need another keystore.  And here’s how I get mine generated:

  1.  Launch Terminal.app  (I’m on Mac.)

  2.  Type the following and hit enter:

keytool -genkey -v -keystore mygame.keystore -alias mygamealias -keyalg RSA -keysize 2048 -validity 999999

Note:  for some reason, I don’t need to use sudo command at all

  1.  It asks me to enter keystore password, and then re-enter new password  (so I created password and made a note of it.)

  2.  Answer whole list of questions, including my name, my organization, my location.

  3.  Terminal spits out a list of my answers and asked if it’s correct.

  4.  Type yes and hit enter

  5.  It asks for keystore password for mygamealias (and tells me to RETURN if same as keystore password), so simply hit enter.

  6.  It will began storing mygame.keystore 

  7.  Done.  (I can find the keystore using file finder search.)

Looks like i’m doing the same thing as you.

I would have thought an error message would appear in the log if the hash key was wrong. I"m seeing no errors.  I’m going to try hunt down another android device to test on.

I also tested with and without the facebook app installed.  The steps to getting this setup are pretty simple, so not sure why it isn’t working for me.