Openssl is not recognized as an internal or external command

后端 未结 15 1691
轻奢々
轻奢々 2020-11-28 00:59

I wish to generate an application signature for my app which will later be integrated with Facebook. In one of Facebook\'s tutorials, I found this command:

k         


        
相关标签:
15条回答
  • 2020-11-28 01:56

    go to bin folder path in cmd and then run following command

    keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64
    

    you will get your key hash

    0 讨论(0)
  • 2020-11-28 02:00

    use this worked for me. please change your Path

    C:\Program Files\Java\jre7\bin keytool -exportcert -alias androiddebugkey -keystore "C:\Users\Ace.android\debug.keystore" | "C:\openssl\bin

    \openssl.exe" sha1 -binary | "C:\openssl\bin\openssl.exe" base64

    0 讨论(0)
  • 2020-11-28 02:01

    it's late answer but it will help to lazy people like me.. add this code to your Application class, there is no need to download openssl and no need to set the path.. only need is just copy this code.. and keyHash will generated in log.

    import com.facebook.FacebookSdk;
    public class MyApplication extends Application {
    
        @Override
        public void onCreate() {
            super.onCreate();
            FacebookSdk.sdkInitialize(getApplicationContext());
            AppEventsLogger.activateApp(this);
            printKeyHash();
        }
    
        private void printKeyHash() {
            try {
                PackageInfo info = getPackageManager().getPackageInfo(
                        getPackageName(), PackageManager.GET_SIGNATURES);
                for (Signature signature : info.signatures) {
                    MessageDigest md = MessageDigest.getInstance("SHA");
                    md.update(signature.toByteArray());
                    Log.i("KeyHash:",
                            Base64.encodeToString(md.digest(), Base64.DEFAULT));
                }
            } catch (PackageManager.NameNotFoundException e) {
                Log.e("jk", "Exception(NameNotFoundException) : " + e);
            } catch (NoSuchAlgorithmException e) {
                Log.e("mkm", "Exception(NoSuchAlgorithmException) : " + e);
            }
        }
    }
    

    and do not forget add MyApplication class in manifest:

    <application
            android:name=".MyApplication"
    </application>
    
    0 讨论(0)
提交回复
热议问题