您的位置:首页 > 移动开发 > Android开发

Ionic打包Android应用签名

2015-09-20 23:25 507 查看


先了解两件事情:

Keytool 是一个有效的安全钥匙和证书的管理工具.

Android 要求所有的程序必须有签名,否则就不会安装该程序。


生成命令

注意:记得将alias_name改一下。
1
$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000
之前忘记修改这个名记造成很大问题。这过程中会问你一些问题:
123456789
Enter keystore password:Re-enter new password:What is your first and last name?  [Unknown]:  phodalWhat is the name of your organizational unit?  [Unknown]:  phodalWhat is the name of your organization?  [Unknown]:  phodalWhat 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/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: