错误,而建设apk与Flutter

olhwl3o2  于 2023-03-04  发布在  Flutter
关注(0)|答案(2)|浏览(134)

我已经试过使用--null-safety模式,但是我的应用程序不工作。当我在emuletor上使用调试模式时,我没有任何问题。有什么想法吗?
这里是错误消息。

flutter build apk 

 Building with sound null safety 

Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

 - package:plugin_platform_interface

For solutions, see https://dart.dev/go/unsound-null-safety

FAILURE: Build failed with an exception.

* Where:
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1070

* What went wrong:
Execution failed for task ':app:compileFlutterBuildRelease'.
> Process 'command 'C:\src\flutter\bin\flutter.bat'' finished with non-zero exit value 1 

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 31s
Running Gradle task 'assembleRelease'...                           33,0s
Gradle task assembleRelease failed with exit code 1

这里是我的pubspec.yaml

name: name
description: desc

publish_to: 'none' 

version: 1.0.16

environment:
  sdk: ">=2.15.1 <3.0.0"
   
dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.5
  particles_flutter: ^0.1.4  
  sqflite: ^2.0.2
  intl: ^0.18.0
  flutter_staggered_grid_view: ^0.6.2
  flex_color_picker: ^2.5.0
  shared_preferences: ^2.0.15
  # image_picker_form_field: ^0.0.1

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^1.0.4

我尝试更新所有依赖项,但仍然不起作用。

6ie5vjzr

6ie5vjzr1#

似乎有些dependencies不支持空安全,要解决这个问题,您可以升级您的依赖项
将软件包升级到最新
运行flutter pub outdated --mode=null-safety以打印所有过期的软件包。,
flutter pub upgrade --null-safety自动升级所有软件包
或者使用下面的命令来运行你的应用程序而不使用null安全。

flutter run --no-sound-null-safety
  • 最好在更新前继续使用git分支 *
unguejic

unguejic2#

我也面临着发布apk的问题。我试着在gradle.properties中改变。

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=false <---- make it false.

然后运行flutter build apk命令

相关问题