Flutter iOS 构建失败:目标 kernel_snapshot 失败:异常:快照创建期间出错:null 构建失败
Posted
技术标签:
【中文标题】Flutter iOS 构建失败:目标 kernel_snapshot 失败:异常:快照创建期间出错:null 构建失败【英文标题】:Flutter iOS build failed: Target kernel_snapshot failed: Exception: Errors during snapshot creation: null build failed 【发布时间】:2020-10-25 03:28:01 【问题描述】:在 android 上运行良好,但当我在 ios 上运行时。它显示了一些警告,但也显示了一个错误。以下是日志。
Launching lib/main.dart on iPhone SE (2nd generation) in debug mode...
(This is taking an unexpectedly long time.)⡿
Compiler message:
../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/snackbar/snack_route.dart:279:8: Error: The
method 'SnackRoute.install' has more required arguments than those of overridden method 'OverlayRoute.install'.
void install(OverlayEntry insertionPoint)
^
../../../../desktop/dev/flutter/packages/flutter/lib/src/widgets/routes.dart:41:8: Context: This is the overridden method ('install').
void install()
^
(This is taking an unexpectedly long time.)⡿../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/routes/default_route.dart:242:9: Error: No named
parameter with the name 'animation'.
animation: animation,
^^^^^^^^^
../../../../desktop/dev/flutter/packages/flutter/lib/src/cupertino/route.dart:435:3: Context: Found this candidate, but the arguments
don't match.
CupertinoFullscreenDialogTransition(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
(This is taking an unexpectedly long time.)⣟../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/snackbar/snack_route.dart:289:18: Error: Too
many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
super.install(insertionPoint);
^
Running pod install... 11.5s
Running Xcode build...
Xcode build done. 63.7s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
/Users/apple/desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.15.1/darwin/Classes/AudioplayersPlugin.m:88:37:
warning: incompatible pointer types sending 'FlutterEngine *' to parameter of type 'NSObject<FlutterBinaryMessenger> * _Nonnull'
[-Wincompatible-pointer-types]
binaryMessenger:_headlessEngine];
^~~~~~~~~~~~~~~
In module 'Flutter' imported from
/Users/apple/desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/audioplayers-0.15.1/darwin/Classes/AudioplayersPlugin.h:2:
/Users/apple/Desktop/dev/upwork/body_alarm/ios/Flutter/Flutter.framework/Headers/FlutterChannels.h:178:74: note: passing argument
to parameter 'messenger' here
binaryMessenger:(NSObject<FlutterBinaryMessenger>*)messenger;
^
1 warning generated.
/Users/apple/desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/vibration-1.4.0/ios/Classes/VibrationPlugin.m:6:4: warning:
'SwiftVibrationPlugin' is only available on iOS 13.0 or newer [-Wunguarded-availability-new]
[SwiftVibrationPlugin registerWithRegistrar:registrar];
^~~~~~~~~~~~~~~~~~~~
In file included from
/Users/apple/desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/vibration-1.4.0/ios/Classes/VibrationPlugin.m:2:
/Users/apple/Desktop/dev/upwork/body_alarm/build/ios/Debug-iphonesimulator/vibration/vibration.framework/Headers/vibration-Swift.h
:213:12: note: 'SwiftVibrationPlugin' has been marked as being introduced in iOS 13.0 here, but the deployment target is iOS 8.0.0
@interface SwiftVibrationPlugin : NSObject <FlutterPlugin>
^
/Users/apple/desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/vibration-1.4.0/ios/Classes/VibrationPlugin.m:6:4: note:
enclose 'SwiftVibrationPlugin' in an @available check to silence this warning
[SwiftVibrationPlugin registerWithRegistrar:registrar];
^~~~~~~~~~~~~~~~~~~~
1 warning generated.
Compiler message:
../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/snackbar/snack_route.dart:279:8: Error: The
method 'SnackRoute.install' has more required arguments than those of overridden method 'OverlayRoute.install'.
void install(OverlayEntry insertionPoint)
^
../../../../desktop/dev/flutter/packages/flutter/lib/src/widgets/routes.dart:41:8: Context: This is the overridden method
('install').
void install()
^
../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/routes/default_route.dart:242:9: Error: No
named parameter with the name 'animation'.
animation: animation,
^^^^^^^^^
../../../../desktop/dev/flutter/packages/flutter/lib/src/cupertino/route.dart:435:3: Context: Found this candidate, but the
arguments don't match.
CupertinoFullscreenDialogTransition(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../../../desktop/dev/flutter/.pub-cache/hosted/pub.dartlang.org/get-1.17.3/lib/src/snackbar/snack_route.dart:289:18: Error: Too
many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
super.install(insertionPoint);
^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Constructing build description
Could not build the application for the simulator.
Error launching application on iPhone SE (2nd generation).
这些是我在这个应用程序中使用的包:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
json_annotation:
audioplayers: ^0.15.1
wakelock:
shared_preferences:
vibration: ^1.4.0
flutter_local_notifications: ^1.1.5+1
flutter_icons: ^1.0.0+1
flutter_launcher_icons: ^0.7.4
url_launcher: ^5.4.2
get: ^1.15.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
build_runner:
json_serializable:
flutter_test:
sdk: flutter
我也尝试创建一个新项目并将之前项目中的所有代码复制到新项目中,但仍然无法正常工作。谁能帮我解决这些问题。
【问题讨论】:
你能发布flutter --version
的输出吗?
【参考方案1】:
您的问题似乎与 get 包有关。你落后了很多版本。较新的版本在调用super.install()
时不传递参数,这是您的错误的来源。
升级到更新版本的软件包可能会解决您的问题。除非您有理由不购买最新版本,否则我建议您将 pubspec.yaml
中的 get: ^1.15.2
行更改为 get: ^3.2.2
,如下所示:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
json_annotation:
audioplayers: ^0.15.1
wakelock:
shared_preferences:
vibration: ^1.4.0
flutter_local_notifications: ^1.1.5+1
flutter_icons: ^1.0.0+1
flutter_launcher_icons: ^0.7.4
url_launcher: ^5.4.2
get: ^3.2.2
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
dev_dependencies:
build_runner:
json_serializable:
flutter_test:
sdk: flutter
当您使用它时,不妨看看您正在使用的所有其他软件包。将它们升级到较新的版本也可能会消除一些其他警告消息。
【讨论】:
以上是关于Flutter iOS 构建失败:目标 kernel_snapshot 失败:异常:快照创建期间出错:null 构建失败的主要内容,如果未能解决你的问题,请参考以下文章
Flutter - http.get 在 macos 构建目标上失败:连接失败
Flutter 构建在 iOS 上失败,但在 android 上工作