Hashkey mismatch android facebook app - android

Downloaded recent facebook android sdk 3.7 and i tried to run sample apps in the sdk. When I tried helloFacebookSample app i got hashkey problem. I searched through web and got my hashkey correct i.e DSygOIIJUkYyHy/duT1e72ZHl5U=.
My app is showing "hashkey not stored" error. When I logged my sample app hashkey I found strange thing happening.
I am using this code:
Toast.makeText(getApplicationContext(),Base64.encodeToString(md.digest(), Base64.DEFAULT), Toast.LENGTH_LONG).show();
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
Toast.makeText(getApplicationContext(),Base64.encodeToString(md.digest(), Base64.DEFAULT), Toast.LENGTH_LONG).show();
Same piece of code is showing different hashkeys
DSygOIIJUkYyHy/duT1e72ZHl5U=
2jmj7l5rSw0yVb/vlWAYkK/YBwk=
and when I try to post status it shows a different hashkey.
DSygOIIJUkYyHy_duT1e72ZHl5U=
I have stored all three hashkeys in my sample app, and it is still showing me this error.

This problem usually comes when hashkey generated by your app doesnt match with the one which you have put in facebook developers site. Try to generate the hashkey programmatically and put it in developers site. Hope this solution helps

The same problem occurred to me , i had no idea what gone wrong ,then i realized that that key store that i used to generate the key hash was a different one ,if you have signed your app you will get a .jks key store file ,you have to specify that path of the file in the code generating the key hash like
keytool -list -v -keystore yourkeystore_path/yourkeystore.jks -alias your_aliase_name
the names of the keystore file and aliases name should be same as the one when you signed your app then your get the correct code for sure.
then there also a work around just write down the code displaying in the error and put it in the keyhash field simple as that...
hope it helps

Related

Android KeyHash Valid when Debug, Invalid when I install the App from APK

I got KeyHash using this.
Of course, I copied this (KeyHash, package name and main activity class) to facebook settings according this.
And when I debug my app it looks fine (I can login and logout how many times I want), but when I create APK and run the app I received common error "invalid key hash the key hash does not match any stored key hash..."
What do I need to except getting right KeyHash and adding it into your Facebook App ID's Android settings?
You have to call
FacebookSdk.sdkInitialize(getApplicationContext());
before calling
FacebookSdk.getApplicationSignature(getApplicationContext());
to avoid getting NULL
This worked fine for me.

Android App Signature Key

I want to get the key-hash from signed signature of my Android App so that I can integrate facebook login in my android app. I have created the signed signature using AndroidTools-->Export Signed Application Package. How can I read the key generated in the signature file.
Solution 1:
Try this link: http://www.helloandroid.com/tutorials/using-facebook-sdk-android-development-part-1. I found that using the Facebook method of getting a Hash Key did not always work as advertised. This link however, has a different method of getting the Hash Key and has pretty much always worked.
Solution 2:
That being said, I always found the simplest thing to do was, let the Facebook SDK tell you what your Hash Key is. This is by far more simpler and shouldn't take more than a couple of minutes.
Step 1: In your Facebook SDK, locate the Util.java class. In that, change this:
private static boolean ENABLE_LOG = false;
to:
private static boolean ENABLE_LOG = true;
Step 2: Create a new Signed APK, transfer to your device and install. If it is already installed, naturally, it will prompt.
Step 3: With your DDMS (Logcat) running and your device connected to the computer, run the application and keep looking for a key mismatch warning. That warning has the actual Hash Key. Copy that key, go to your Facebook Developer page and add the new key to the list.

Android Google Plus getCurrentPerson returns null

When I'm calling plusClient.getCurrentPerson() I am getting NULL.
Method onConnected(Bundle...) called after a successful login:
#Override
public void onConnected(Bundle bundle)
{
if (plusClient.getCurrentPerson() == null)
{
Log.e("DD", "Person is null !");
}
}
I have added SHA1 directly from eclipse (Window->Preferences->Android->Build). I don't know what I am doing wrong!
SHA1 fingerprint from Eclipse ADT
Client ID for installed applications
Simple API access
In my case I forgot to enable permission for google-plus
Hope it works...Any doubt let me know
Check from scratch:
Sometime person info may be null
check : PERMISSIONS
Important things to do:
Enable Google plus API
Enable Google Maps Android API
If you test locally then add sha1 key in eclipse-->window-->preference option-->Android-->Build
OR
You can generate SHA1 key through command prompt
keytool -list -v -keystore "C:\Users\User.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
If you are publishing app in play-store then you need to change SHA1 key in google console
because in local SHA1 key is different . After doing signedApk SHA1 key is different
While generating signed apk -->in the last screen -->you can see SHA1 key
After adding in google console you will get API key
Add this key in Manifest file
I just found out that you need to pass multiple scopes when you're building the PlusClient object:
PlusClient plusClient = new PlusClient.Builder(this, this, this).setScopes(Scopes.PLUS_LOGIN, Scopes.PLUS_PROFILE ,"https://www.googleapis.com/auth/userinfo.email").build();
I encountered this today. This is an old post but I think others should know how I fixed this in Android Studio and what was the source of the problem.
I spent the last 6 hours with this and the problem was that a week ago I changed the package name using Refactoring from Android Studio but something must have gotten wrong since would always return me null, even though I refactored the project back to it's original package.
I fixed this by creating a new project, without closing the original, but using the same package name and the same login code from the original project and to my surprise it worked. The name of the new project was different but I named the package the same as the old one and it only had a button and code to manage the connection and nothing else.
The new project would read the data as it should and now the old project somehow got back on his feet and started reading the current user.
I closed the project with Close Project option from the File menu.
Best regards !
Please check your phone network. you can use those codes below to check:
Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this);
#Override
public void onResult(LoadPeopleResult result) {
Log.d(TAG, "result.getStatus():" + result.getStatus());
}
if the result status is network error. the current person will be null.
I'm in China, so as you know if we want to connect the google service , sometimes we need a good agent 。
This looks like a permissions issue. I added payment details in the Google API Console and it magically started working.

Session Provided to a request in unopened state

Facebook friend picker sample in the Facebook SDK 3.0 shows error dialoge box.
the message box says:
'com.facebook.Facebook Exception : Session Provided to a request in unopened state.'
I had this exact error, if you are running this from Eclipse then there is a good chance there is a more detailed error in the log cat. For me I found the real error was that my Android hashkey did not match up with the hashkey I had provided to Facebook.
Double check that the hashkey you are using is correct. See this Answer for setting up your hashkey
Key hash for Android-Facebook app
Further, using the Keytool did not help me for my HashKey, instead I followed the advice on this guide:
https://developers.facebook.com/docs/getting-started/facebook-sdk-for-android/3.0/
In step 4, see Troubleshooting, and modify the code to output your HashKey and use that one instead. The hashkey I had generated from Keytool was much different than this one. After that recompile everything, it should work fine.

Android error : Cannot recover key

i have a problem when i want to run my android application, this is the error message :
Error generating final archive: java.security.UnrecoverableKeyException: Cannot recover key
how to solve this problem?
thankyou
Keystore password and key password both need to be the same. You must be getting this error if they are not same.
Either you have enter your keystore password or Alias password is wrong, that is why you got Cannot recover key Exception.enter correct password for both keystore and alias.
Sometimes if the key is invalid due to expiration,etc then this also happened
I had the same problem, and the solution was as follows:
1- When I changed the key store password,the returns was "error in the password who has tempered the key", in that case the keystore pass is incorrect.
2-If you have the following error, "cannot recover key", in that case the storepass is correct but the password for that alias is incorrect, i remembered my pass and changing, the problem is gone.
you have problem with your key.
This will give you how to info on keys
http://developer.android.com/tools/publishing/app-signing.html#debugmode
To change key in debug mode
(To do so in Eclipse/ADT, go to Windows > Preferences > Android > Build.)
This is one nightmare faced and documentation seem rather not clear on figuring your way out... I had the same issue but I understood after brainstorming.
Now in simplest term...
When you opt in for app signing, Google makes you create a key you use to sign in your app. This is like your legacy key (App signing certificate) and is the bedrock.
Now in uploading, another key is mapped to you which is a second layer ID to you, this lets you update your app.
Now whenever you loose the alias/password you contact google via your mail and they will tell you to create a new keystore that they will reset the old one(upload key) with because they have they legacy key already. Thus at any point in app lifecycle, you don't need to have your legacy key because they have housed it for you already.

Categories

Resources