Ionic打包Android应用签名

先了解两件事情:

  • Keytool 是一个有效的安全钥匙和证书的管理工具.
  • Android 要求所有的程序必须有签名,否则就不会安装该程序。

生成命令

注意:记得将alias_name改一下。

     
     
1
     
     
$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000

之前忘记修改这个名记造成很大问题。这过程中会问你一些问题:

     
     
1
2
3
4
5
6
7
8
9
     
     
Enter keystore password:
Re-enter new password:
What is your first and last name?
[Unknown]: phodal
What is the name of your organizational unit?
[Unknown]: phodal
What is the name of your organization?
[Unknown]: phodal
What is the name of your City or Locality?

注意:如果你想要将应用发布到一些应用市场的时候,将保存好你的签名,出现签名不一致的话,就说明有问题了。。。


构建 Android应用

生成 release包

Cordova提供了一组设备相关的API,通过这组API,移动应用能够以JavaScript访问原生的设备功能,如摄像头、麦克风等。

     
     
1
     
     
$ cordova build --release android

Method 1: Use jarsigner directly

This is the method I used to use and it isn’t Cordova CLI specific (it’s part of the Java SDK build tools and this method is part of their standard documentation). After you have created your APK (cordova build android --release) you can run the following command:

     
     
1
     
     
$ jarsigner - verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore release_key_name.keystore app_name.apk alias_name

Jarsigner will prompt for the password and sign the APK.


Method 2: Part of the CLI workflow

The ant.properties thing needs an update in this writeup as of today, since Android now uses gradle. For gradle, therelease-signing.properties as mentioned below somehow didn't work for me. I created ‘build-extras.gradle’ (in the same directory as build.gradle i.e. platforms/android) containing the reference to the file containing the keystore information, the content of build-extras.gradle is as follows:

ext.cdvReleaseSigningPropertiesFile='release-signing.properties'

As mentioned in build.gradle this file is always executed (https://cordova.apache.org/doc...

The name of this properties file can be anything, content is signing information like:

storeFile=C:/Users/ra/../key_related/cra_an_key.keystore
storeType=jks
keyAlias=cra

Also I turned to Java 6 (version 23), b'cos of known certificate signing issues. And finally gave the command :

cordova build android -release


参考链接:


http://wincn.net/2015/08/06/Ionic%E6%89%93%E5%8C%85Android%E5%BA%94%E7%94%A8%E6%8C%87%E5%8D%97/


http://ilee.co.uk/Sign-Releases-with-Cordova-Android/


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值