Assuming you're using the latest 3.0 SDK, try the following two options:
Option 1: (Windows)
%KEYTOOLPATH%keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%.androiddebug.keystore | %OPENSSLPATH%openssl sha1 -binary | %OPENSSLPATH%openssl base64
Example:
C:Program Files (x86)Javajdk1.7.0_09inkeytool" -exportcert -alias androiddebugkey -keystore "C:Home.androiddebug.keystore" | "C:OpenSSLinopenssl" sha1 -binary | "C:OpenSSLinopenssl" base64
Use the password: android
Option 2: (Print key hash sent to FB)
(A variation of Facebook SDK for Android - Example app won't work)
Add this code to your activity:
try {
PackageInfo info = getPackageManager().getPackageInfo("your package name, e.g. com.yourcompany.yourapp]", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
Example:
In HelloFacebookSampleActivity, make the following temporary modification to the onCreate() method
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
PackageInfo info = getPackageManager().getPackageInfo("com.facebook.samples.hellofacebook", PackageManager.GET_SIGNATURES);
for (Signature signature : info.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
Log.d("KeyHash:", Base64.encodeToString(md.digest(), Base64.DEFAULT));
}
} catch (NameNotFoundException e) {
} catch (NoSuchAlgorithmException e) {
}
...
}
Run your sample and you should get logcat output on the KeyHash tag similar to:
12-20 10:47:37.747: D/KeyHash:(936): 478uEnKQV+fMQT8Dy4AKvHkYibo=
Use that value in Facebook's App Dashboard settings for your app.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…