无法通过 Visual Studio cordova 构建已签名的 android 包 [英] Cannot build signed android package through visual studio cordova

查看:18
本文介绍了无法通过 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.

我遵循了本指南: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)Androidandroid-sdk (TaskId:11)
1>  JAVA_HOME=C:Program Files (x86)Javajdk1.7.0_55 (TaskId:11)
1>  uild.json (TaskId:11)
1>  Reading build config file: uild.json (TaskId:11)
1>  platformsandroidcordova
ode_modulesqq.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 (platformsandroidcordovalibuild.js:475:27) (TaskId:11)
1>      at Object.module.exports.run (platformsandroidcordovalibuild.js:529:16) (TaskId:11)
1>      at platformsandroidcordovauild:36:22 (TaskId:11)
1>      at _fulfilled (platformsandroidcordova
ode_modulesqq.js:798:54) (TaskId:11)
1>      at self.promiseDispatch.done (platformsandroidcordova
ode_modulesqq.js:827:30) (TaskId:11)
1>      at Promise.promise.promiseDispatch (platformsandroidcordova
ode_modulesqq.js:760:13) (TaskId:11)
1>      at platformsandroidcordova
ode_modulesqq.js:574:44 (TaskId:11)
1>      at flush (platformsandroidcordova
ode_modulesqq.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 ""platformsandroidcordovauild.bat" --release "--buildConfig=uild.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)

我做错了什么?好像不能解析JSON?

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

推荐答案

这个问题是因为默认的 build.json 有一个 NodeJS JSON 解析器不喜欢的 BOM.您可以通过多种方式解决此问题,但最简单的方法是使用 Visual Studio 的二进制编辑器打开文件.

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.

右键单击 build.json,选择打开方式...",然后选择二进制编辑器"从列表中.您应该会看到如下内容:

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天全站免登陆