0

因此,过去几个月我一直在使用 Angular-Nativescript,并且有一个项目都使用 Angular 9。短暂休息后,我开始在另一台机器上工作,该机器说项目正在开发,但不记得它是在 Angular 7 上. 我运行脚本来升级 Angular,它直接升级到版本 10,这是我的问题开始的地方。在所有安装、升级、迁移、下载和重新安装之后,我能够生成、运行和提供 Angular 组件,但我无法构建 Nativescript。tns build android 命令总是运行到 55% 然后抛出错误

命令 gradlew.bat 失败,退出代码为 1

我不知道在哪里可以找到更详细的信息。我尝试在批处理文件中回显不同的步骤,但不知道是什么问题。如果我没有使用正确的术语,我深表歉意,因为我对前端世界还很陌生。

一些支持信息......我已经到了在我的机器上使用模拟器的地步。我安装了运行模拟器的 Android Studio。因此,当我运行 tns 设备时,我可以看到一个示例,如随附的屏幕截图所示。据我所知,应该创建一个 apk 文件并将其传输到模拟器,但我不知道在哪里查看文件是否正在创建但只是没有被传输。

如果有人知道这是什么,我们将不胜感激获得正确的修复错误。

控制台文本是

tns build android
Preparing project...
Hash: b88f22b61097dd6429ce
Version: webpack 4.44.0
Time: 72ms
Built at: 07/27/2020 18:00:16
  Asset       Size  Chunks             Chunk Names
main.js  958 bytes       0  [emitted]  main
Entrypoint main = main.js
[0] ./src/index.js 386 bytes {0} [built]

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/
Project successfully prepared (android)
Building project...
Gradle build...
         + setting applicationId
         + applying user-defined configuration from C:\Repos\Sothecom\ManageTurns\src\Sothecom.ManageTurns.MobileWeb\baseline\App_Resources\Android\app.gradle
         + using android X library androidx.legacy:legacy-support-v4:1.0.0
         + adding nativescript runtime package dependency: nativescript-optimized-with-inspector
         + adding aar plugin dependency: C:\Repos\Sothecom\ManageTurns\src\Sothecom.ManageTurns.MobileWeb\baseline\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar
Command gradlew.bat failed with exit code 1

tns 信息是

tns info
√ Getting NativeScript components versions information...
√ Component nativescript has 6.7.8 version and is up to date.
√ Component tns-core-modules has 6.5.12 version and is up to date.
√ Component tns-android has 6.5.3 version and is up to date.
‼ Update available for component tns-ios. Your current version is 6.3.0 and the latest available version is 6.5.2.

我在 Windows 10 笔记本电脑上 设备已被识别

4

1 回答 1

0

事实是,Nativescript 很容易毫无理由地看似随机地失败。我希望权威人士会在这件事上大喊大叫(并在此过程中启发我),但我已经有很多集像你所拥有的一样,现在有一个特别奇怪的集(为什么Nativescript 静态绑定生成器无缘无故失败,也没有任何信息?),所以我目前对这个平台的维护者(或者他们缺乏相关文档)并不感到慈善。

除了我过去的悲伤经历,我可以建议您遵循以下步骤:

  1. 从项目根目录运行./node_modules/.bin/update-ns-webpack --deps --configs以重新生成“干净”的 webpack 配置。如果您在此处有任何自定义(例如复制其他文件类型),您可能需要稍后将它们放回原处。
  2. 删除目录node_modules, hooks, 和platforms (如果您使用自定义钩子,您需要稍后替换它们)
  3. tns 构建 android --log 跟踪

如果失败,日志跟踪可能会给您一些见解。之前的步骤是其他人通常建议的“蛮力”解决方法,我发现它们通常是有效的(但不是万灵药)。

祝您的特定变体好运!

于 2020-07-29T00:07:23.397 回答