Android Studio获取SHA1(获取SHA1的通用方法)

来源:互联网 发布:java调用restful api 编辑:程序博客网 时间:2024/05/18 01:14

第一步、打开Android Studio的Tools->Open Terminal 
第二步、输入命令:keytool -v -list -keystore keystore.jks 
【一定要记得加上 -v 参数,不然只能看到SHA1,没有MD5.keystore.jks,需要替换为你自己的密钥所在路径和文件名】 
(获取debug模式下,命令为)

keytool -list -v -keystore ~/.android/debug.keystore

有可能会报如下错误(特别是Ubuntu系统)

The program ‘keytool’ can be found in the following packages

原因如下:

/usr/lib/jvm/jdk1.8.0_25/bin isn’t on your $PATH. 
Just use the full path to invoke it.

解决方式就是将keytool加上全路径,如在我电脑上如下:

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">/usr/lib/jvm/jdk1<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.7</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.0</span>/bin/keytool <span class="hljs-attribute" style="box-sizing: border-box;">-list</span> <span class="hljs-attribute" style="box-sizing: border-box;">-v</span> <span class="hljs-attribute" style="box-sizing: border-box;">-keystore</span> ~<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">/</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>android/debug<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>keystore</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

其中/usr/lib/jvm/jdk1.7.0/bin/按照自己电脑配置

0 0
原创粉丝点击