简体   繁体   English

构建 Cordova 发布 apk

[英]Building Cordova release apk

I am finding it extremely difficult to get my heard around signing my app under the new cordova 5.0 guideline我发现在新的cordova 5.0指南下签署我的应用程序非常困难

this is what i have done这就是我所做的

(bongoapp)project root
 ->build.json
 ->phistoKey.keystore
 ->www

this is what i have inside my build.json file这是我在 build.json 文件中的内容

{
 "android": {
     "release": {
         "keystore": "phistoKey.keystore",
         "storePassword": "",
         "alias": "phistoKey",
         "password" : "",
         "keystoreType": ""
     }
 }

} }

when i try当我尝试

cordova build --release

or或者

cordova build android --release

I get error stating我收到错误说明

Keystore file does not exist: C:\wamp\www\towncrier\platforms\android\..\..\phistoKey.keystore

I will be glad if anyone can help cos I am on a deadline TODAY.如果有人能帮助我,我会很高兴,因为我今天要到最后期限了。 thank you谢谢你

The way I do it in new Cordova CLI (with gradle) is using the options that cordova give us for doing it without make our own script or doing it manually in different steps.我在新的 Cordova CLI(带有 gradle)中执行此操作的方式是使用cordova 为我们提供的选项,无需编写我们自己的脚本或在不同的步骤中手动执行此操作。 In my case, I have created a file in platforms/android directory, with the name release-signing.properties .就我而言,我在platforms/android目录中创建了一个文件,名称为release-signing.properties The content of this should be the configuration for signing your apk, something like:这里面的内容应该是你的apk签名的配置,比如:

key.store=/PATH/TO/YOUR/KEYSTORE
key.alias=your_alias
key.store.password=key_store_pass
key.alias.password=key_store_alias

With this file created, you just need to run the standard command, cordova build android --release , and it will generate new release APK in your output directory ( platforms/android/outputs/apk/yourapp-release.apk )创建此文件后,您只需要运行标准命令cordova build android --release ,它就会在您的输出目录 ( platforms/android/outputs/apk/yourapp-release.apk ) 中生成新的发行版 APK

In cordova 6.2.0在科尔多瓦 6.2.0

cd cordova/ #change to root cordova folder
platforms/android/cordova/clean #clean if you want
cordova build android --release -- --keystore="/path/to/keystore" --storePassword=password --alias=alias_name #password will be prompted if you have any

I do the following in a shell script to build and sign an APK.我在 shell 脚本中执行以下操作来构建和签署 APK。 This assumes that the app is named "bongoapp" and that your Cordova project and keystore file (phistoKey.keystore) are located in the same folder as the shell script.这假设应用程序名为“bongoapp”,并且您的 Cordova 项目和密钥库文件 (phistoKey.keystore) 与 shell 脚本位于同一文件夹中。

# Run this script in the bongoapp folder to build and sign a release APK.
# Hint: the password is "bongoapp"

# Build the release APK
echo "Building Android release APK"
cordova build android --release

# Sign the APK
echo "Signing Android release APK"
jarsigner -verbose -certs -sigalg SHA1withRSA -digestalg SHA1 -keystore phistoKey.keystore platforms/android/ant-build/MainActivity-release-unsigned.apk bongoapp_alias
jarsigner -verbose -certs -verify platforms/android/ant-build/MainActivity-release-unsigned.apk
zipalign -v 4 platforms/android/ant-build/MainActivity-release-unsigned.apk platforms/android/ant-build/bongoapp.apk

echo "Done, output file is located here -> platforms/android/ant-build/bongoapp.apk"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM