本文主要是介绍修改keystore密码别名等,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
修改Android签名证书keystore的密码、别名alias以及别名密码
之前在测试Eclipse ADT的Custom debug keystore自定义调试证书的时候,发过一篇关于调试证书规格的博文:Eclipse ADT的Custom debug keystore所需证书规格,提到过自定义调试证书的密码和alias命名以及alias密码都是有规矩的。其实Android应用开发接入各种SDK时会发现,有很多SDK是需要靠package name和keystore的指纹hash来识别的(百度地图SDK、Facebook SDK等等…),这样如果使用默认自动生成的debug keystore的话就会给开发调试工作带来一些麻烦。这时可以通过修改正式的release keystore,生成一份“遵守规矩”的临时自定义调试证书给开发时用,就方便多了,具体方法如下:
1. 首先当然是先复制一份正式证书出来作为要修改为的临时调试证书。这里我们这支的keystore 的密码为hahaha,alias为silence,alias的密码为xixixi
2. 修改keystore密码的命令(keytool为JDK带的命令行工具):
keytool -storepasswd -keystore my.keystore
其中,my.keystore是复制出来的证书文件,执行后会提示输入证书的当前密码(hahaha),和新密码(android)以及重复新密码(android)确认。这一步需要将密码改为android。
3. 修改keystore的alias:
keytool -changealias -keystore my.keystore -alias my_name -destalias androiddebugkey
这一步中,my_name是证书中当前的alias(silence),-destalias指定的是要修改为的alias,这里按规矩来,改为androiddebugkey!这个命令会先后提示输入keystore的密码(android,已经在第二步中进行了修改)和当前alias的密码(xixixi)。
4. 修改alias的密码:
keytool -keypasswd -keystore my.keystore -alias androiddebugkey
这一步执行后会提示输入keystore密码(android),alias密码(xixixi),然后提示输入新的alias密码(android),同样,按规矩来,改为android!
以上几个操作执行后,my.keystore就是符合规矩的debug keystore了,接着在Eclipse的ADT设置中选中这个custom debug keystore即可,如下:
同时还可以看到证书的MD5以及SHA1指纹。
PS:以上3步命令行并没有先后顺序。
key.alias= 别名
此别名一开始以为可以随便写,后来多次尝试发现乱写打包一定不成功,此别名要与第一次生成签名时的别名一至,由于签名不是我申请的,申请签名的同事也忘记了签名的别名,如此只好找工具看一下签名的信息了,其实工具不用找了,在jdk中有
直接keytool -list -v -keystore xxxx.keystore -storepass 密码 签名的信息就有了
C:\SoftwareInstallSpace\Java\jdk1.8.0_77\bin>keytool -printcert -file D:\ForComputer\chromDownload\JinfengAppV2p0\META-INF\ANDROID1.RSA
badging D:\ForWork\JG_c10n2.7_20170109.apk
package: name='com.zondy.police' versionCode='10' versionName='2.7' platformBuil
dVersionName=''
sdkVersion:'14'
targetSdkVersion:'17'
uses-permission: name='android.permission.READ_PHONE_STATE'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.CHANGE_WIFI_STATE'
uses-permission: name='android.permission.VIBRATE'
uses-permission: name='android.permission.RECEIVE_BOOT_COMPLETED'
uses-permission: name='android.permission.CAMERA'
uses-permission: name='android.permission.SYSTEM_ALERT_WINDOW'
uses-permission: name='android.permission.RECORD_AUDIO'
uses-permission: name='android.permission.RECEIVE_USER_PRESENT'
uses-permission: name='android.permission.WAKE_LOCK'
uses-permission: name='android.permission.WRITE_EXTERNAL_STORAGE'
uses-permission: name='android.permission.READ_EXTERNAL_STORAGE'
uses-permission: name='android.permission.WRITE_SETTINGS'
uses-permission: name='android.permission.MOUNT_UNMOUNT_FILESYSTEMS'
uses-permission: name='android.permission.ACCESS_COARSE_LOCATION'
uses-permission: name='android.permission.ACCESS_FINE_LOCATION'
uses-permission: name='android.permission.ACCESS_LOCATION_EXTRA_COMMANDS'
uses-permission: name='android.permission.CHANGE_NETWORK_STATE'
uses-permission: name='android.permission.READ_LOGS'
uses-permission: name='android.permission.CAMERA'
uses-permission: name='android.permission.CALL_PHONE'
uses-permission: name='android.permission.GET_TASKS'
application-icon-160:'res/drawable-xhdpi-v4/ic_launcher.png'
application-icon-240:'res/drawable-xhdpi-v4/ic_launcher.png'
application-icon-320:'res/drawable-xhdpi-v4/ic_launcher.png'
application-icon-480:'res/drawable-xhdpi-v4/ic_launcher.png'
application: label='' icon='res/drawable-xhdpi-v4/ic_launcher.png'
application-debuggable
feature-group: label=''uses-feature: name='android.hardware.camera'uses-feature: name='android.hardware.camera.autofocus'uses-feature: name='android.hardware.location'uses-implied-feature: name='android.hardware.location' reason='requested andro
id.permission.ACCESS_COARSE_LOCATION permission, requested android.permission.AC
CESS_FINE_LOCATION permission, and requested android.permission.ACCESS_LOCATION_
EXTRA_COMMANDS permission'uses-feature: name='android.hardware.location.gps'uses-implied-feature: name='android.hardware.location.gps' reason='requested a
ndroid.permission.ACCESS_FINE_LOCATION permission'uses-feature: name='android.hardware.location.network'uses-implied-feature: name='android.hardware.location.network' reason='request
ed android.permission.ACCESS_COARSE_LOCATION permission'uses-feature: name='android.hardware.microphone'uses-implied-feature: name='android.hardware.microphone' reason='requested and
roid.permission.RECORD_AUDIO permission'uses-feature: name='android.hardware.screen.landscape'uses-implied-feature: name='android.hardware.screen.landscape' reason='one or
more activities have specified a landscape orientation'uses-feature: name='android.hardware.screen.portrait'uses-implied-feature: name='android.hardware.screen.portrait' reason='one or m
ore activities have specified a portrait orientation'uses-feature: name='android.hardware.telephony'uses-implied-feature: name='android.hardware.telephony' reason='requested a te
lephony permission'uses-feature: name='android.hardware.touchscreen'uses-implied-feature: name='android.hardware.touchscreen' reason='default feat
ure for all apps'uses-feature: name='android.hardware.wifi'uses-implied-feature: name='android.hardware.wifi' reason='requested android.p
ermission.ACCESS_WIFI_STATE permission, and requested android.permission.CHANGE_
WIFI_STATE permission'
main
other-activities
other-receivers
other-services
supports-screens: 'small' 'normal' 'large' 'xlarge'
supports-any-density: 'true'
locales:
densities: '160' '240' '320' '480'
native-code: 'armeabi'
这篇关于修改keystore密码别名等的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!