Error while building apk with Flutter

huangapple go评论67阅读模式
英文:

Errore while building apk with Flutter

问题

I have already tried using the --null-safety mode but than my app doesn't work.
我已经尝试使用--null-safety模式,但我的应用程序仍然无法运行。

When I use the debug mode on the emuletor I have no problems.
当我在模拟器上使用调试模式时,没有问题。

Any idea?
有什么想法吗?

Here the error message.
以下是错误消息。

 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

Here my pubspec.yaml
以下是我的pubspec.yaml

name: name
描述: 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

I try to update all the dependencies but still don't work.
我尝试更新所有依赖项,但仍然无法运行。

英文:

I have already tried using the --null-safety mode but than my app doesn't work.
When I use the debug mode on the emuletor I have no problems.
Any idea?

Here the error message.

flutter build apk 

 Building with sound null safety 

Error: Cannot run with sound null safety, because the following dependencies
don&#39;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 &#39;C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle&#39; line: 1070

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

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

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

BUILD FAILED in 31s
Running Gradle task &#39;assembleRelease&#39;...                           33,0s
Gradle task assembleRelease failed with exit code 1

Here my pubspec.yaml

name: name
description: desc

publish_to: &#39;none&#39; 

version: 1.0.16

environment:
  sdk: &quot;&gt;=2.15.1 &lt;3.0.0&quot;
   
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

I try to update all the dependencies but still don't work.

答案1

得分: 0

看起来有一些 dependencies 不支持空安全,要解决这个问题,你可以升级你的依赖项。

升级依赖项到最新版本

运行
flutter pub outdated --mode=null-safety 来列出所有过时的包。

然后运行 flutter pub upgrade --null-safety 来自动升级所有的包。

或者使用以下命令在没有空安全的情况下运行你的应用程序。

flutter run --no-sound-null-safety

在更新之前最好保留正在工作的 git 分支

英文:

Seems some dependencies not supporting null-safety and to solve this you can upgrade your dependencies

> To upgrade packages upto date

Run
flutter pub outdated --mode=null-safety to print all outdated packages.,

And flutter pub upgrade --null-safety to upgrade all packages automatically

> Or use below command to run your application without null-safety.

flutter run --no-sound-null-safety

Better to keep working git branch before update

答案2

得分: 0

我也面临着发布APK的问题。我尝试在gradle.properties中进行更改。

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=false <---- 将其设置为false。

然后运行flutter build apk命令。

英文:

I also facing release apk issue. I tried to change in the gradle.properties.

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=false &lt;---- make it false.

Then run flutter build apk command

huangapple
  • 本文由 发表于 2023年2月27日 18:18:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75579189.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定