启动我的flutter应用程序时出现问题(我认为这是一个构建问题)

问题描述 投票:0回答:1

如果问题解释得不够好,我很抱歉,希望如果有什么需要显示为问题信息的,可以进一步补充。

基本上,我对 Flutter 还很陌生。我已经创建了 myApp 并对其做了一些工作。由于一切正常,突然构建失败,现在一切都显示为未定义(我没有添加新的依赖项或其他东西,只是在检查新引入的功能是否正常工作后进行了重建)。

我尝试了颤振:

  1. 扑扑干净
  2. flutter 包获取
  3. flutter 包更新
  4. flutter 酒吧获取
  5. 删除 pubspeck.lock

但我似乎无法运行它。请帮助新人:)。

基本上在 yaml 文件中我没有做太多更改,只是添加了几个依赖项和启用的资产。这是 pubspec.yaml 文件:

name: app_name
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1

environment:
  sdk: '>=3.2.4 <4.0.0'

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  agora_uikit: ^1.3.7
  agora_rtc_engine: ^6.2.6
  agora_rtm: ^1.5.9
  shared_preferences: ^2.2.2
  flutter_riverpod: ^2.4.9
  app_popup_menu: ^1.0.0
  modal_bottom_sheet: ^2.1.2
  circular_menu: ^2.0.1

dev_dependencies:
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/Logo.png
  

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

这是main.dart的代码:

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:myApp/pages/splash_screen.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return ProviderScope(
      child: MaterialApp(
        theme: ThemeData(
          colorScheme: ColorScheme.fromSeed(seedColor: Colors.green),
          useMaterial3: true,
        ),
        home: const SplashScreen(),
      ),
    );
  }
}

再次运行“flutter pub get”后,依赖关系已解决,但是当尝试再次启动应用程序时,我在终端中收到以下异常。

FAILURE: Build failed with an exception.

* What went wrong:
Gradle could not start your build.
> Cannot create service of type TaskExecuter using method ProjectExecutionServices.createTaskExecuter() as there is a problem with parameter #14 of type ReservedFileSystemLocationRegistry.
   > Cannot create service of type ReservedFileSystemLocationRegistry using method ProjectExecutionServices.createReservedFileLocationRegistry() as there is a problem with parameter #1 of type List<ReservedFileSystemLocation>.
      > Could not create service of type ExecutionHistoryStore using ExecutionGradleServices.createExecutionHistoryStore().
         > Cannot lock execution history cache (/Users/user/Desktop/myApp/my_app/android/.gradle/7.5/executionHistory) as it has already been locked by this process.

* 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.
flutter dart build
1个回答
0
投票

感谢@AppSolves 提供指导,解决此问题。在停止、清理 gradle build 并重新启动我的电脑后,问题已解决。按照此处的步骤进行操作无法使用 ProjectExecutionServices 创建类型为 TaskExecuter 的服务

© www.soinside.com 2019 - 2024. All rights reserved.