【问题标题】:My gradlew.bat keeps failing on tns build android我的 gradlew.bat 在 tns build android 上一直失败
【发布时间】:2020-07-27 23:54:31
【问题描述】:

所以过去几个月我一直在使用 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 笔记本电脑

【问题讨论】:

    标签: android nativescript gradlew tns nativescript-schematics


    【解决方案1】:

    事实是,Nativescript 很容易毫无理由地看似随机地失败。我希望权威人士会对此大喊大叫(并在此过程中启发我),但我已经有很多像你一样的剧集,现在有一个特别奇怪的剧集(@987654321 @),所以我目前对这个平台的维护者(或他们缺乏相关文档)感到不仁慈。

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

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

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

    祝你的特定变体好运!

    【讨论】:

    • 非常感谢 Trempo。我还没有尝试过你的建议,但很高兴听到有人有同样的挫败感。 Angular 和 Nativescipt 都缺乏向后兼容性非常令人恼火,尤其是一旦一切正常,它就很棒了。过去几天我一直在到处复制相关文件,例如 webpack.config.js、各种 node_module 文件夹等,决定休息几天,让你知道我明天会怎样
    • 很高兴地说我现在正在构建并升级到运行时错误。你的建议很棒,因为我带领我走上了另一条安装、重新安装、降级和几乎破解一些源文件的道路,例如从 node_modules/@nativescript/angular/index.d.ts 中删除随机“导入类型”并降级打字稿.现在它正在创建 apk 文件,但在模拟器上我收到了几个错误 setTimeout 未定义来自 vendor.js ......但将接受今天的胜利并在明天与那个战斗。再次感谢。希望你在自己的方面取得进步
    • 我试图走开,但凭直觉,我使用 tns preview 进行了尝试,它在我的手机上运行,​​所以我会拿着它运行
    猜你喜欢
    • 2019-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-06
    • 2020-09-05
    • 1970-01-01
    • 2018-03-19
    相关资源
    最近更新 更多