当前位置: 首页 > 知识库问答 >
问题:

错误:执行任务失败:应用程序:compileFlutterBuildDebug

岳研
2023-03-14

我得到这些错误,当我运行我的代码。请任何想法,我怎么能修复这些?我升级了颤振,pubspeck.lock.我提到代码是旧的,我试图升级

lib/screens/search/createnewfood.dart:147:30: Error: The argument type 'void Function(String)' can't be assigned to the parameter type 'void Function(String?)?' because 'String?' is nullable and 'String' isn't.
                  onChanged: (String unit) {
                             ^
lib/screens/search/createnewfood.dart:184:27: Error: Property 'isEmpty' cannot be accessed on 'String?' because it is potentially null.
Try accessing using ?. instead.
                    value.isEmpty ? 'Please enter a number' : null,
                          ^^^^^^^
lib/screens/search/foodpage.dart:24:28: Error: Can't use the default List constructor.
Try using List.filled instead.
  var dropDownValues = new List<String>();
                           ^
lib/screens/search/foodpage.dart:85:41: Error: The argument type 'Color?' can't be assigned to the parameter type 'Color' because 'Color?' is nullable and 'Color' isn't.
 - 'Color' is from 'dart:ui'.
                      color: Colors.grey[200],
                                        ^
lib/screens/search/foodpage.dart:116:43: Error: The argument type 'Color?' can't be assigned to the parameter type 'Color' because 'Color?' is nullable and 'Color' isn't.
 - 'Color' is from 'dart:ui'.
                        color: Colors.grey[200],
                                          ^
lib/screens/search/foodpage.dart:177:46: Error: The argument type 'Color?' can't be assigned to the parameter type 'Color' because 'Color?' is nullable and 'Color' isn't.
 - 'Color' is from 'dart:ui'.
        border: Border.all(color: Colors.grey[200]),
                                             ^
lib/screens/search/foodpage.dart:265:16: Error: The getter 'Provider' isn't defined for the class '_FoodPageState'.      
 - '_FoodPageState' is from 'package:fitnessapp/screens/search/foodpage.dart' ('lib/screens/search/foodpage.dart').      
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Provider'.
    var user = Provider.of<User>(context);
               ^^^^^^^^
lib/screens/search/foodpage.dart:340:34: Error: The argument type 'void Function(String)' can't be assigned to the parameter type 'void Function(String?)?' because 'String?' is nullable and 'String' isn't.
                      onChanged: (String unit) {
                                 ^
lib/screens/search/foodpage.dart:368:51: Error: Method 'validate' cannot be called on 'FormState?' because it is potentially null.
 - 'FormState' is from 'package:flutter/src/widgets/form.dart' ('/C:/Users/valen/Downloads/flutter5/flutter/packages/flutter/lib/src/widgets/form.dart').
Try calling using ?. instead.
                    if (_foodFormKey.currentState.validate()) {
                                                  ^^^^^^^^
lib/services/client.dart:12:31: Error: Method not found: 'get'.
    var response = await http.get(url);
                              ^^^
lib/services/client.dart:33:31: Error: Method not found: 'get'.
    var response = await http.get(url);
                              ^^^
Unhandled exception:
FileSystemException(uri=org-dartlang-untranslatable-uri:package%3Aprovider%2Fprovider.dart; message=StandardFileSystem only supports file:* and data:* URIs)
#0      StandardFileSystem.entityForUri (package:front_end/src/api_prototype/standard_file_system.dart:34:7)
#1      asFileUri (package:vm/kernel_front_end.dart:623:37)
#2      writeDepfile (package:vm/kernel_front_end.dart:763:21)
<asynchronous suspension>
#3      FrontendCompiler.compile (package:frontend_server/frontend_server.dart:586:9)
<asynchronous suspension>
#4      starter (package:flutter_frontend_server/server.dart:85:12)
<asynchronous suspension>
#5      main (file:///C:/b/s/w/ir/cache/builder/src/flutter/flutter_frontend_server/bin/starter.dart:13:24)
<asynchronous suspension>



FAILURE: Build failed with an exception.

* Where:
Script 'C:\Users\valen\Downloads\flutter5\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1102

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

>

  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。运行--扫描以获得完整的见解。

    获取更多帮助https://help.gradle.org

  • 共有2个答案

    万高洁
    2023-03-14

    如果您不想与这些空安全人员打交道,您可以将sdk版本降级为“

    你基本上可以在这里pubspec.yaml文件和更改sdk版本;

    强宾白
    2023-03-14

    看起来它是引入空安全之前2年的代码。我建议您应该一个接一个地解决每个错误。

    第一个:你应该写String? unit
    第二个:它应该是value!. is空因为它可能是null
    第三个:List

    更新您的新版本:
    您使用的是cloud\u firestore和firebase\u auth的旧版本,您应该从pubspec升级到最新版本。yaml最新版本编号可在此处找到:
    https://pub.dev/packages/firebase_auth
    https://pub.dev/packages/cloud_firestore

     类似资料:
    • 当我要构建apk时,我收到此错误。 执行任务“app:transformClassesWithDexForDebug”失败。 这是错误的截图

    • 每当我运行、制作或清理项目时, 出现此错误消息。 我已经检查了我的资源文件好几次,没有出现致命错误。只有png图标和xml文件。 我不知道“-1”是什么意思。。 在我的主java文件中,有“无法解析符号R”错误。 我的应用程序昨晚启动得很好,但当我今天早上醒来运行android studio时,它失败了。 我该怎么办? 这是我的猎物 在下面,我添加了我的全部gradle输出,谢谢。 执行任务:[:

    • 我正在尝试构建一个颤振应用程序,该应用程序已经在其他系统中开发,但我得到的梯度误差如下所示: 正在启动lib/main。sdk gphone64 arm64上的dart处于调试模式。。。正在运行Gradle任务“assembleDebug”。。。警告:映射新的nshttp://schemas.android.com/repository/android/common/02给老奶奶http://sc

    • 我已经尝试了几乎所有的其他主题,但我有同样的问题在我的rss阅读器应用程序。我该怎么修好它? 我得到了这个错误: 错误:任务“:app:TransformClassesWithMultiDexListForDebug”执行失败。com.android.build.api.transform.transformException:com.android.ide.common.Process.proc

    • 错误:任务执行失败 ': app:使用合并Java Res For Debug转换资源'。 com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException: APK META-INF/LICENSE File1中复制的重复文件: C:\用户Jithin-P

    • 我正在使用这个库https://github.com/mikepenz/MaterialDrawer 当我尝试运行我的项目时,我得到以下错误: 错误: 错误:任务': app: dexDebug'的执行失败。com.android.ide.common.process.ProcessExc0019:org.gradle.process.internal.ExecExc0019: Process'命