4

I have a strange problem. I am trying integrate Facebook to my app. The functionality part is working just fine but the problem is it works only when connected from my PC directly i.e if connected my phone to eclipse and send the app it is work fine. If I extract the apk and install it from my phone directly The app doesn't log me in, doesn't create session etc etc.

Can somebody let me know what is wrong here?

Update 1:

Created the key as recommended by SK9 by following official facebook developer website.

C:\Java\jdk1.7.0_10\bin>keytool -exportcert -alias myAppfull -key store myAppfull | C:\openssl-0.9.8k_X64\bin\openssl sha1 -binary | C:\openssl-0.9.8k_X64\bin\openssl base64 I get the password prompt. I enter password that I used for export in eclipse and it gave a code. I entered in developers page.

Where: myAppfull is alias name and keystore that I used when I export using eclipse.

still the same problem? Is there anything that I Am missing?

Thanks!

Update 2:

It worked! Thanks!! Might be useful for others. Check my answer below!

TheDevMan
  • 5,656
  • 12
  • 67
  • 133

3 Answers3

10

Thanks to SK9 and Vizz. I did some more research and figured out how to fix this issue.

THIS IS USEFUL FOR PEOPLE WHO ARE USING ECLIPSE TO CREATE THE KEYSTORE FOR RELEASE.

1) Open command prompt and give the path of JDK Bin folder in my case (C:\Java\jdk1.7.0_10\bin).

2) Copy this code keytool -exportcert -alias "youraliasnamethatwasgivenwhileexportineclipse" -keystore yourkeystorethatsavedwhileexportineclipse > c:\openssl\bin\release.txt

3) Now you need to enter password, Password = "samepasswordthatyouenterwhilecreatingthekeystoreineclipse".

4) See in openssl Bin folder you will get a file with the name of release.txt

5) Now change directory to your open ssl folder in my case: C:\openssl-0.9.8k_X64\bin\

6) copy the following code and paste openssl sha1 -binary release.txt > release_sha.txt

7) you will get release_sha.txt in openssl bin folder

8) Again copy following code and paste openssl base64 -in release_sha.txt > release_base64.txt

9) you will get release_base64.txt in openssl bin folder

10) open release_base64.txt file - Bingo you have the hashkey - copy the key.

Paste this beside your debug key in the facebook developer website. It should start working!

TheDevMan
  • 5,656
  • 12
  • 67
  • 133
  • Exactly. In future it's best to follow official documentation: Android docs (keygen) and Facebook SDK docs cover this. – SK9 Jun 26 '13 at 02:17
  • keytool error: java.lang.Exception: Keystore file does not exist: myfile Get this error, does the keystore file need to be in specific folder? – TheLD Sep 22 '13 at 11:08
  • Not required but you will have to give an exact folder name while using it on keytool.. Follow the instructions step by step in the above answer, you will successfully create the release key. – TheDevMan Sep 24 '13 at 05:33
2

Check that the signing certificates for the APK and registered on Facebook developer account match up. It seems like they don't.

See Facebook #5. Add your release key hash to the list.

SK9
  • 29,437
  • 32
  • 112
  • 154
0

I face the exact same issue long time ago. The problem seems to appear (only in Windows) when you mix both commands in one single line (the result key is corrupted). What I did was run the commands separately. I don't remember the exact way I did it, but I fount this, which seems pretty similar to what I found.

Exporting keystore cert
keytool -exportcert -alias <insert the name of your alias here> -keystore <insert the route of your key here> -storepass android -keypass android > namefile.bin

Converting to sha1
<insert the route of your \bin\openssl here > sha1 -binary namefile.bin > namefile.sha1

Converting to base64
<insert the route of your \bin\openssl here > base64 -in namefile.sha1 -out namefile.base64

Done, Android hash key for Facebook app is:
<insert the route of your \bin\openssl here > base64 -in namefile.sha1

Source: Another Stackoverflow Question

Community
  • 1
  • 1
gian1200
  • 3,567
  • 2
  • 27
  • 57
  • The above is for debug version. Similarly we have to use it for release version only difference is we use the same keystore that was created for releasing using eclipse. – TheDevMan Jun 26 '13 at 02:15
  • Thanks for the feedback @TheDevMan. I improved and generalized the answer – gian1200 Jun 26 '13 at 02:39