http://cordova.apache.org/docs/en/latest/guide/platforms/android/index.html#project-configuration
本篇使用 cordova 6.0版本
1、在<your-project>/platforms/android
目录下添加gradle.properties
可添的属性值如下
如gradle.properties:
#In <your-project>/platforms/android
cdvVersionCode=1
cdvMinSdkVersion=15
cdvReleaseSigningPropertiesFile:../../keystore/release-signing.properties
cdvDebugSigningPropertiesFile:../../keystore/release-signing.properties
2、release-signing.properties 内容参考如下:
storeFile=relative/path/to/keystore.p12
storePassword=SECRET1
storeType=pkcs12
keyAlias=DebugSigningKey
keyPassword=SECRET2
3、从build.gradle
也可看
if (ext.cdvDebugSigningPropertiesFile == null && file('debug-signing.properties').exists())
签名文件也可以配置debug-signing.properties文件放在platform/android下
4、问题项目git管理可看出platform是不默认传的,
使用时将其全保存到另一个文件夹下
使用hooks命令将
gradle.properties
文件添加到platform/android目录下。
5、hooks介绍
http://cordova.apache.org/docs/en/latest/guide/appdev/hooks/index.html
hooks.js内容如下 使用node.js的
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var rootdir = process.argv[2];
console.log("adnroid keystore hooks start ");
if (rootdir) {
var __dirname = process.env.PWD;
var destPath = path.join(__dirname, "platforms", "android", "gradle.properties");
console.log("destPath:" + destPath);
fs.exists(destPath, function(exists) {
if (!exists) {
//复制文件
var sourceFile = path.join(__dirname, "keystore", "gradle.properties");
var readStream = fs.createReadStream(sourceFile);
var writeStream = fs.createWriteStream(destPath);
readStream.pipe(writeStream);
}
console.log("adnroid keystore hooks end");
});
}
将其添加到根目录下的config.xml
调用hooks 命令行执行 ionic prepare android
参考 ;
http://rensanning.iteye.com/blog/2030824