Flutter 集成测试不起作用,找不到 uri

Flutter integration test not working, uri not found

编辑:tl;dr 如果您在添加新包时遇到“URI 的目标不存在”错误,请尝试关闭 Android Studio 项目并重新打开它。

我刚刚开始对我的 Flutter 应用程序进行集成测试,但由于某种原因它找不到 integration_testing uri。

我已完成所有步骤 here,包括:

  1. 正在更新我的 pubspec.yaml
dev_dependencies:
  integration_test:
    sdk: flutter
  flutter_test:
    sdk: flutter
  1. 正在创建 integration_test/app_test.dart 目录和文件:

  2. 运行 pub get, flutter clean.

  3. 在最新的 flutter 版本上,医生没有问题:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.3, on macOS 11.3.1 20E241 darwin-arm, locale
    en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version
    32.0.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] IntelliJ IDEA Community Edition (version 2021.3)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

• No issues found!

这是完整的pubspec.yaml

name: squabbit
description: A new Flutter application.

# 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 used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.8.0+80

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^1.1.0
  firebase_auth: ^1.1.3
  firebase_storage: ^8.0.5
  cloud_firestore: ^1.0.7
  firebase_crashlytics: ^2.0.2
  rxdart: 0.26.0
  intl: ^0.17.0
  #  file_picker: ^1.1.1
  google_sign_in: ^5.2.3
  image_picker: 0.7.4
  cached_network_image: ^3.0.0
  flutter_google_places: ^0.3.0
  google_maps_webservice: ^0.0.19
  carousel_pro: ^1.0.0
  flutter_launcher_icons: ^0.9.0
  package_info: ^2.0.0
  mime: ^0.9.7
  google_fonts: 2.1.0
  enum_to_string: 1.0.14
  shared_preferences: ^2.0.5
  algolia: 1.0.1
  flutter_email_sender: ^5.0.0
  device_info_plus: ^1.0.1
  material_design_icons_flutter: 4.0.5955
  visibility_detector: ^0.2.2
  fluttertoast: ^8.0.7
  in_app_review: ^2.0.2
  cloud_functions: ^3.0.0
  firebase_analytics: ^8.2.0

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^0.1.2
  in_app_purchase: ^0.5.2
  firebase_messaging: ^11.2.6
  firebase_remote_config: ^2.0.2

dev_dependencies:
  integration_test:
    sdk: flutter
  flutter_test:
    sdk: flutter

flutter_icons:
  android: false
  ios: true
  image_path: "assets/icon/icon.png"


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

# The following section is specific to Flutter.
flutter:
  assets:
    - assets/images/

  # 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

我这样定义 pubspec.lock 并且有效:

dev_dependencies:
  integration_test:
  flutter_test:
    sdk: flutter

我尝试添加另一个包,但遇到了同样的问题。结果在 Android Studio 中关闭了项目,re-opening 它解决了问题。