不能通过visual studio cordova构建签名的Android包 [英] Cannot build signed android package through visual studio cordova

查看:266
本文介绍了不能通过visual studio cordova构建签名的Android包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Visual Studio 2015 Cordova工具为我的Android应用程序构建签名的发行包。
我使用Cordova 5.1.1,这需要我提供一个build.json文件的构建过程,告诉应用程序在哪里的密钥库和什么密码正在使用。
然而,当我添加build.json文件时,我无法成功构建发布。



我遵循本指南:



选择前三个字节作为截图,并删除它们,然后保存文件。解析器现在应该接受该文件,签名将按预期工作。


I am trying to build a signed release package for my Android application using Visual Studio 2015 Cordova Tools. I am using Cordova 5.1.1, which requires that I supply the build process with a build.json file, telling the application where the keystore are and what password is using. However when I add the build.json file, I am not able to make a successful build to release.

I followed this guide: https://github.com/Microsoft/cordova-docs/tree/master/tutorial-package-publish#android

And got this error (with path edited out):

1>  ANDROID_HOME=C:\Program Files (x86)\Android\android-sdk (TaskId:11)
1>  JAVA_HOME=C:\Program Files (x86)\Java\jdk1.7.0_55 (TaskId:11)
1>  \build.json (TaskId:11)
1>  Reading build config file: \build.json (TaskId:11)
1>  \platforms\android\cordova\node_modules\q\q.js:126 (TaskId:11)
1>                      throw e; (TaskId:11)
1>                            ^ (TaskId:11)
1>  SyntaxError: Unexpected token  (TaskId:11)
1>      at Object.parse (native) (TaskId:11)
1>      at parseOpts (\platforms\android\cordova\lib\build.js:475:27) (TaskId:11)
1>      at Object.module.exports.run (\platforms\android\cordova\lib\build.js:529:16) (TaskId:11)
1>      at \platforms\android\cordova\build:36:22 (TaskId:11)
1>      at _fulfilled (\platforms\android\cordova\node_modules\q\q.js:798:54) (TaskId:11)
1>      at self.promiseDispatch.done (\platforms\android\cordova\node_modules\q\q.js:827:30) (TaskId:11)
1>      at Promise.promise.promiseDispatch (\platforms\android\cordova\node_modules\q\q.js:760:13) (TaskId:11)
1>      at \platforms\android\cordova\node_modules\q\q.js:574:44 (TaskId:11)
1>      at flush (\platforms\android\cordova\node_modules\q\q.js:108:17) (TaskId:11)
1>      at process._tickCallback (node.js:355:11) (TaskId:11)
1>  Command finished with error code 1: cmd /s /c ""\platforms\android\cordova\build.bat" --release "--buildConfig=\build.json"" (TaskId:11)
1>ERROR building one of the platforms : error : cmd: Command failed with exit code 1
1>  You may not have the required environment or OS to build this project (TaskId:11)
1>MDAVSCLI : error : cmd: Command failed with exit code 1
1>Done executing task "MdaVsCli" -- FAILED. (TaskId:11)

What am I doing wrong? It seems like it cant parse the JSON?

解决方案

This issue is caused because the default build.json has a BOM that the NodeJS JSON parser doesn't like. You can fix this in a number of ways, but the simplest is to open the file using Visual Studio's Binary editor.

Right-click build.json, select "Open With...", then choose the "Binary Editor" from the list. You should see something like this:

Select the first three bytes as in the screenshot, and delete them, then save the file. The parser should now accept the file, and signing will work as expected.

这篇关于不能通过visual studio cordova构建签名的Android包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆