我完全不明白这个过程。我已经能够导航到Java SDK中包含keytool的文件夹。虽然我一直得到错误openssl不识别为内部或外部命令。问题是,即使我能让它工作,我该做什么,然后做什么?


当前回答

keytool -exportcert -alias androiddebugkey -keystore “C:\Users**Deepak**.android\debug.keystore” |“C:\Users\Deepak\ssl\bin\openssl” sha1 -binary |“C:\Users\Deepak\ssl\bin\openssl” base64

2上述命令的变化 1.Deepak===替换为您的系统用户名 2.C:\Users\Deepak\ssl===替换您的Open ssl路径

运行此命令并获得如下输出

C:\Users\Deepak>keytool -exportcert -alias androiddebugkey -keystore "C:\Users\D eepak.android \调试。keystore" | "C:\Users\Deepak\ssl\bin\openssl" sha1 -二进制 | "C:\Users\Deepak\ssl\bin\openssl" base64 输入keystore密码:****** ga0RGNY ******************=

其他回答

请试试这个:

public static void printHashKey(Context pContext) {
        try {
            PackageInfo info = pContext.getPackageManager().getPackageInfo(pContext.getPackageName(), PackageManager.GET_SIGNATURES);
            for (Signature signature : info.signatures) {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(signature.toByteArray());
                String hashKey = new String(Base64.encode(md.digest(), 0));
                Log.i(TAG, "printHashKey() Hash Key: " + hashKey);
            }
        } catch (NoSuchAlgorithmException e) {
            Log.e(TAG, "printHashKey()", e);
        } catch (Exception e) {
            Log.e(TAG, "printHashKey()", e);
        }
    }

在你的应用程序中运行:

FacebookSdk.sdkInitialize(getApplicationContext());
Log.d("AppLog", "key:" + FacebookSdk.getApplicationSignature(this)+"=");

或:

public static void printHashKey(Context context) {
    try {
        final PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES);
        for (android.content.pm.Signature signature : info.signatures) {
            final MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(signature.toByteArray());
            final String hashKey = new String(Base64.encode(md.digest(), 0));
            Log.i("AppLog", "key:" + hashKey + "=");
        }
    } catch (Exception e) {
        Log.e("AppLog", "error:", e);
    }
}

然后看看日志。

结果应该以“=”结尾。

解是基于这里和这里。

我也遇到了同样的问题,下面是我如何解决它的方法

keytool -list -alias androiddebugkey -keystore <project_file\android\app\debug.keystore>
    private fun generateKeyHash(): String? {try {
    val info =packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES)
    for (signature in info.signatures) {
        val md: MessageDigest = MessageDigest.getInstance("SHA")
        md.update(signature.toByteArray())
        return String(Base64.encode(md.digest(), 0))
    }
} catch (e: Exception) {
    Log.e("exception", e.toString())
}
    return "key hash not found"
}

步骤1->在您的系统中打开CMD

步骤2->C:\程序文件\Java\jdk1.6.0_43\bin>

步骤3->keytool -list -v -keystore C:\Users\leon\.android\debug. exeKeystore -alias androiddebugkey -storepass android -keypass android

你得到SHA1值点击这个链接你转换你的SHA1值为哈希键

我100%肯定这个链接会帮助你