Facebook issue corona sdk 2014.2393

I have run into a very weird issue with facebook. When I use the debug.keystore sharing with facebook works fine. However when I use a development/private keystore which I created (which is required to publish your app on google play) i get the following error…

“invalid key hash. The key hash 5mgcal8wwZa0ao5M776o3/0QJ0g does not match any stored key hashes. Configure your app key hashes at blah blah facebook url.” 

Now this is not even the correct key hash that I have (and I checked numerous times with multiple methods.) However this error occurred with the debug.keystore (with a different key hash) but just in case I added a “=” at the end and now the debug.keystore works fine. Figuring it might work again I tried adding an “=” with the above key hash but still the same error occurs. Why is it that the debug.keystore works fine but the private one is giving me this error?

Thanks for your help

-Brandon.

Hi Brandon,

As a first test, can you upgrade to the latest public build of Corona (2511) and then implement Facebook through the plugin method? It’s now a plugin, which means that you need to add it to your plugins in build.settings, but otherwise the functions/APIs remain the same. Here’s a link to the documentation:

http://docs.coronalabs.com/plugin/facebook/index.html

Best regards,

Brent

Actually I have already tried that but then my entire game crashes this is the error I get on my device… (If I get rid of game network it happens with admobs and so on…

Screenshot_2014-12-18-16-28-16.png

Here are my build.settings (with the plugin)  and it makes no sense that it breaks completely when I update corona…

settings = { orientation={ default = "portrait", }, iphone = { plist = { UIStatusBarHidden=true, UIApplicationExitsOnSuspend = false, MinimumOSVersion = "4.3", UIAppFonts = { "fonts/ComicRelief.ttf" }, FacebookAppID = "1496569143940849", -- replace XXXXXXXXX with your facebook appId CFBundleURLTypes = { { CFBundleURLSchemes = { "fb1496569143940849", -- replace XXXXXXXXX with your facebook appId } } } }, }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_WIFI\_STATE", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.READ\_PHONE\_STATE", "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", }, { googlePlayGamesAppId = "929433348294", }, }, plugins = { ["facebook"] = { publisherId = "com.coronalabs" }, }, { ["CoronaProvider.ads.admob"] = { publisherId = "com.coronalabs" }, }, { ["plugin.google.iap.v3"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true }, }, }, { ["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true }, }, }, }

Hi @bkove12,

It looks like you’ve structured the tables incorrectly in your plugins table. You have opened and closed brackets in the wrong places, or added extra tables where they shouldn’t be. All plugins should be stated as key-value pairs within the “plugins” table, where the key is the name of the plugin, i.e…

[lua]

    [“plugin.google.iap.v3”] =

[/lua]

… and the value is the table with the various other parameters:

[lua]

    {

        publisherId = “com.coronalabs”,

        supportedPlatforms = { android=true }

    },

[/lua]

So, the next plugin would be defined right after that, as another key-value pair, but still residing inside the “plugins” table.

Hope this helps,

Brent

Hi again,

This tutorial should really help you, actually… it shows how to properly set up the plugins table, but also the entire build.settings file. Proper indentation is extremely important, and this tutorial discusses that as well. :slight_smile:

http://coronalabs.com/blog/2014/07/08/tutorial-understanding-build-settings/

Brent

I have looked at all of this many times. I’m confused about the plugins part i’m not sure how to set it up with multiple plugins. could you give me an example? (I’m new to corona and programming in general if you couldn’t tell).

-Thanks!

Hi @bkove12,

It would be like this… notice how each plugin is contained as its own block within the “plugins” table… and of course, that entire "plugins table is contained as a block within the “settings” table. As I mentioned, using proper indentation in your code will help a lot to see exactly how these tables must be nested.

[lua]

    plugins =

    {

        --first

        [“facebook”] =

        {

            publisherId = “com.coronalabs”

        },

        --next

        [“CoronaProvider.ads.admob”] =

        {

            publisherId = “com.coronalabs”

        },

        --next

        [“plugin.google.iap.v3”] =

        {

            publisherId = “com.coronalabs”,

            supportedPlatforms = { android=true }

        },

        --next

        [“CoronaProvider.gameNetwork.google”] =

        {

            publisherId = “com.coronalabs”,

            supportedPlatforms = { android=true }

        },

    },

[/lua]

I appreciate all the help but now when I open the .apk on my phone it just says it stopped working and closes -_-’

In this case, something else is likely broken. Can you post your entire build.settings file as it stands now?

settings = { orientation={ default = "portrait", }, iphone = { plist = { UIStatusBarHidden=true, UIApplicationExitsOnSuspend = false, MinimumOSVersion = "4.3", UIAppFonts = { "fonts/ComicRelief.ttf" }, FacebookAppID = "1496569143940849", -- replace XXXXXXXXX with your facebook appId CFBundleURLTypes = { { CFBundleURLSchemes = { "fb1496569143940849", -- replace XXXXXXXXX with your facebook appId } } } }, }, android = { usesPermissions = { "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_WIFI\_STATE", "android.permission.ACCESS\_NETWORK\_STATE", "android.permission.READ\_PHONE\_STATE", "com.android.vending.BILLING", "com.android.vending.CHECK\_LICENSE", }, { googlePlayGamesAppId = "929433348294", }, }, plugins = { --first ["facebook"] = { publisherId = "com.coronalabs" }, --next ["CoronaProvider.ads.admob"] = { publisherId = "com.coronalabs" }, --next ["plugin.google.iap.v3"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, --next ["CoronaProvider.gameNetwork.google"] = { publisherId = "com.coronalabs", supportedPlatforms = { android=true } }, }, }

Thanks again for looking at this I really appreciate it.

I’m not sure what is causing this. Do you have an updated error report? If the app crashes before it runs, you may need to gather a report from the console log. Can you do so as described in this guide?

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

My problem is whenever I run the logcat the screen goes crazy with text. I know I need to narrow it down to just show my app stuff but I have no idea how to do that. :confused:

Hmmm… can you try removing the “googlePlayGamesAppId” key from its own table? I think it’s supposed to be stated directly within the “android” table as its own key-value pair. So, instead of this:

[lua]

{

googlePlayGamesAppId = “929433348294”,

},

[/lua]

Do this…

[lua]

googlePlayGamesAppId = “929433348294”,

[/lua]

I know this is like trying to find a needle in a haystack, but eventually something will turn up…

Brent

So it actually works in terms of opening the app. It asks for google network stuff now as well which is great. However it looks like ad.mob might be causing it to crash now. Anytime ad.mob is called my game crashes. Would it have to do with build settings? Thanks.

So i fixed admob by changing it to the version 2 in the build settings ([“plugin.google.play.services”]). So now that everything seems to be working with the newer version of corona we are back to the original issue facebook is back to doing what it did before. :confused:

Regarding the key signing, have you read these tutorials:

http://coronalabs.com/blog/2013/07/30/understanding-facebook-authentication/

http://coronalabs.com/blog/2014/08/26/tutorial-understanding-android-app-signing/

It’s too easy to find some tutorial or command somewhere and blindly type it in and get what appears to be expected results.  You also have to make sure Corona SDK is using the keystore you generated.

Rob

I have actually spent hours looking at these before. I assure you I have not just copied and pasted the command lines. I substituted all the necessary data. I have also made sure that the app is being built with my keystore and proper alias. I have followed these directions to a T and i’m still getting this result.

When you generate your keyhash, there are several commands chained together with | characters.  What happens if you run the first command with out the rest of the commands?

The other thing that I don’t know that you’ve done is to take the keyhash that Facebook says you should be using in it’s log output and applied that as your keyhash?  Of course you will need to make a couple of edits, but that should have been documented in the two tutorials. 

Rob

I’m not entirely sure how to get the facebook logs to see the hash its calling for. If its logcat it goes crazy on my computer and I cant isolate the facebook error.

It’s unfortunate that Google still spews as many messages as they do.  You just have to be diligent and dig through looking for the Facebook messages.

You could try something like:

adb logcat | grep -i facebook

This will show any line that has the string “facebook” in it (ignoring case).  That might help.

Rob