Flutter:命令 PhaseScriptExecution 失败,退出代码非零

Posted

技术标签:

【中文标题】Flutter:命令 PhaseScriptExecution 失败,退出代码非零【英文标题】:Flutter: Command PhaseScriptExecution failed with a nonzero exit code 【发布时间】:2020-06-27 20:30:19 【问题描述】:

这是一个生产中的应用程序。我已经更改了一些逻辑,试图获取我已将其本地化为另一个国家/地区的 dateTime,然后突然出现一些关于 dart html 的错误,但我不记得确切是什么,所以我尝试重建项目,它是抱怨使用新的构建系统,到目前为止我尝试过:

将系统更改为旧版 扑干净 更新可可足类动物。 删除 podfile.lock pod 更新 pod 安装 包升级 颤振升级

这些都没有起作用。

当更改为 legacy 时,出现了 13 个错误,其中一个抱怨 dart:html not found,所以我将它添加到依赖项和 dev dev 依赖项中,但仍然没有。 我还评论了 intl 包,因为发生这种情况时我正在使用它,并且包得到了却什么也没有。

任何想法如何处理这个?

这是完整的控制台 Xcode 输出:

>     2020-03-16 17:55:17.549 xcodebuild[56626:765857]  DTDeviceKit: deviceType from 3ad4f96e876e8222a72563420303530067367818 was NULL
>     ** BUILD FAILED **
> 
> 
> Xcode's output: ↳



  **Skipped Warnings about deprecated methods, because of char limits and previously builds despite the warnings.** 


> 
>     Compiler message:
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.16.0/lib/src/http_request_data_reader.dart:11:8:
> Error: Not found: 'dart:html'
>     import 'dart:html';
>            ^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart:6:8:
> Error: Not found: 'dart:html'
>     import 'dart:html';
>            ^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.16.0/lib/src/http_request_data_reader.dart:28:10:
> Error: Type 'HttpRequest' not found.
>       Future<HttpRequest> _getString(String url, HttpRequest xhr) 
>              ^^^^^^^^^^^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.16.0/lib/src/http_request_data_reader.dart:28:46:
> Error: Type 'HttpRequest' not found.
>       Future<HttpRequest> _getString(String url, HttpRequest xhr) 
>                                                  ^^^^^^^^^^^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart:34:18:
> Error: 'HttpRequest' isn't a type.
>       final _xhrs = <HttpRequest>;
>                      ^^^^^^^^^^^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.16.0/lib/src/http_request_data_reader.dart:20:23:
> Error: Method not found: 'HttpRequest'.
>         var request = new HttpRequest();
>                           ^^^^^^^^^^^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.16.0/lib/src/http_request_data_reader.dart:28:46:
> Error: 'HttpRequest' isn't a type.
>       Future<HttpRequest> _getString(String url, HttpRequest xhr) 
>                                                  ^^^^^^^^^^^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/intl-0.16.0/lib/src/http_request_data_reader.dart:29:35:
> Error: 'HttpRequest' isn't a type.
>         var completer = new Completer<HttpRequest>();
>                                       ^^^^^^^^^^^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart:58:34:
> Error: 'Blob' isn't a type.
>           var blob = xhr.response as Blob ?? Blob([]);
>                                      ^^^^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart:46:15:
> Error: The method 'HttpRequest' isn't defined for the class
> 'BrowserClient'.
>      - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart').
>     Try correcting the name to the name of an existing method, or defining a method named 'HttpRequest'.
>         var xhr = HttpRequest();
>                   ^^^^^^^^^^^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart:58:42:
> Error: The method 'Blob' isn't defined for the class 'BrowserClient'.
>      - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart').
>     Try correcting the name to the name of an existing method, or defining a method named 'Blob'.
>           var blob = xhr.response as Blob ?? Blob([]);
>                                              ^^^^
>     ../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart:59:20:
> Error: The method 'FileReader' isn't defined for the class
> 'BrowserClient'.
>      - 'BrowserClient' is from 'package:http/src/browser_client.dart' ('../../Developer/flutter/.pub-cache/hosted/pub.dartlang.org/http-0.12.0+4/lib/src/browser_client.dart').
>     Try correcting the name to the name of an existing method, or defining a method named 'FileReader'.
>           var reader = FileReader();
>                        ^^^^^^^^^^
>     Unhandled exception:
>     FileSystemException(uri=org-dartlang-untranslatable-uri:dart%3Ahtml;
> message=StandardFileSystem only supports file:* and data:* URIs)
>     #0      StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:33:7)
>     #1      asFileUri (package:vm/kernel_front_end.dart:604:37)
>     #2      writeDepfile (package:vm/kernel_front_end.dart:799:21)
>     <asynchronous suspension>
>     #3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:472:15)
>     <asynchronous suspension>
>     #4      _FlutterFrontendCompiler.compile (package:flutter_frontend_server/server.dart:38:22)
>     #5      starter (package:flutter_frontend_server/server.dart:149:27)
>     #6      main (file:///b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:8:30)
>     #7      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:32)
>     #8      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
> 
>     Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
>     Failed to build bundle.
>     Failed to package /Users/[user]/StudioProjects/[projectName]/ios/...
>     Command PhaseScriptExecution failed with a nonzero exit code
>     note: Using new build system
>     note: Planning build
>     note: Constructing build description
> 
> Could not build the precompiled application for the device.
> 
> Error launching application on [user].

编辑:我的 Podfile 中还有“平台:ios,'11.0'”,并且 iOS 部署目标在 Pod 设置中设置为 11.0。

编辑 2:这是我使用的包:

依赖关系:flutter:sdk:flutter

flutter_localizations: sdk: 颤振

flutter_cupertino_localizations:^1.0.1

geoflutterfire:^2.0.3+5

firebase_storage:^3.0.6

cloud_firestore:^0.12.9+6

firebase_core:^0.4.0+9

firebase_auth:^0.14.0+5

firebase_messaging:^6.0.9

firebase_database: ^3.0.7

firebase_admob:^0.9.0+7

flutter_facebook_login: ^3.0.0

font_awesome_flutter: ^8.5.0

image_picker: ^0.6.1+11

图片:^2.1.4

rxdart: ^0.22.1

位置:^2.3.5

google_maps_flutter:^0.5.20+1

地理编码器:^0.2.1

google_sign_in:^4.0.11

提供者:^4.0.4

flutter_inapp_purchase:^2.0.4

http: ^0.12.0+4

url_launcher: ^5.2.5

国际:^0.16.0

cloud_functions:^0.4.1+4

apple_sign_in: ^0.1.0

flutter_signin_button:^1.0.0

json_annotation: ^3.0.1

notification_permissions:^0.4.4

html_unescape: ^1.0.1+3

cupertino_icons: ^0.1.2

dev_dependencies: flutter_test:sdk:flutter build_runner:^1.7.3 json_serializable: ^3.2.5

【问题讨论】:

【参考方案1】:

intl 包需要正确配置才能在 Flutter 上运行。

当你导入它时,不要使用import 'package:intl/intl_browser.dart';,insead 使用下面的(每个都有它的用途,所以请参阅最适合你的文档):

import 'package:intl/date_symbol_data_local.dart';
import 'package:intl/intl.dart';
import 'package:intl/intl_standalone.dart';

【讨论】:

我没有使用 dart:html... 它是 intl 和其他一些包的一部分。我刚从头开始新项目,使用相同的包,它编译得很好。我不知道这个出了什么问题......我确定的一件事是我不打算制作一个网络应用程序,这个“browser_client.dart:6:8:”仅用于网络应用程序,所以错误是这个方向的东西,但我不知道发生了什么。我尝试了flutter config --no-enable-web ...以防万一我以某种方式启用了网络,但仍然无法正常工作。 您是否正确配置了intl 包?您必须以正确的方式导入它,否则它会加载浏览器版本,您的 intl 导入看起来如何?你在用import 'package:intl/intl_browser.dart';吗? 不,我没有,但我看到了这个 import 'package:intl/date_symbol_data_http_request.dart';我没有使用它。我评论了它,现在得到这个错误flutter dyld:Library not loaded:@rpath/AppAuth.framework/AppAuth所以我必须找到一种方法来摆脱它,看看导入是否有问题。 还要检查您是否使用最新版本的intl 库并执行flutter clean 好的,谢谢,我明天试一试,如果成功了再告诉你

以上是关于Flutter:命令 PhaseScriptExecution 失败,退出代码非零的主要内容,如果未能解决你的问题,请参考以下文章

Flutter 命令本质之 Flutter tools 机制源码深入分析

Flutter 命令在 Windows 命令提示符下不起作用

Flutter 命令本质之 Flutter tools 机制源码深入分析

Flutter 命令本质之 Flutter tools 机制源码深入分析

Flutter 命令本质之 Flutter tools 机制源码深入分析

命令行执行flutter doctor无响应原因追踪及解决