我对颤动很陌生,所以可能有一个明显的解决方案,但我看不到它。
每当我flutter test
在我的应用程序(或任何应用程序,见下文)中运行时,我都会收到以下错误:
00:00 +0: loading /Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart
Compiler message:
file:///var/folders/tr/3tvv8zcd4q302zs0bgbs1h240000gn/T/flutter_test_listener.652XY4/listener.dart:7:8: Error: Error when reading 'file:///Users/johanh/.pub-cache/hosted/pub.dartlang.org/test-1.5.0/lib/src/runner/plugin/remote_platform_helpers.dart': No such file or directory
import 'package:test/src/runner/plugin/remote_platform_helpers.dart';
^
file:///var/folders/tr/3tvv8zcd4q302zs0bgbs1h240000gn/T/flutter_test_listener.652XY4/listener.dart:11:8: Error: Error when reading 'file:///Users/johanh/.pub-cache/hosted/pub.dartlang.org/test-1.5.0/lib/src/runner/vm/catch_isolate_errors.dart': No such file or directory
import 'package:test/src/runner/vm/catch_isolate_errors.dart';
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:14:8: Error: Error when reading 'file:///Users/johanh/.pub-cache/hosted/pub.dartlang.org/test-1.5.0/lib/src/frontend/async_matcher.dart': No such file or directory
import 'package:test/src/frontend/async_matcher.dart'; // ignore: implementation_imports
^
00:02 +0: loading /Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:283:1: Error: Type 'AsyncMatcher' not found.
AsyncMatcher matchesGoldenFile(dynamic key) {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:324:1: Error: Type 'AsyncMatcher' not found.
AsyncMatcher matchesReferenceImage(ui.Image image) {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:530:1: Error: Type 'AsyncMatcher' not found.
AsyncMatcher meetsGuideline(AccessibilityGuideline guideline) {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:538:1: Error: Type 'AsyncMatcher' not found.
AsyncMatcher doesNotMeetGuideline(AccessibilityGuideline guideline) {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:1569:38: Error: Type 'AsyncMatcher' not found.
class _MatchesReferenceImage extends AsyncMatcher {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:1625:34: Error: Type 'AsyncMatcher' not found.
class _MatchesGoldenFile extends AsyncMatcher {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:1822:46: Error: Type 'AsyncMatcher' not found.
class _MatchesAccessibilityGuideline extends AsyncMatcher {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:1841:51: Error: Type 'AsyncMatcher' not found.
class _DoesNotMatchAccessibilityGuideline extends AsyncMatcher {
^
00:03 +0: loading /Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart file:///var/folders/tr/3tvv8zcd4q302zs0bgbs1h240000gn/T/flutter_test_listener.652XY4/listener.dart:20:5: Error: Method not found: 'catchIsolateErrors'.
catchIsolateErrors();
^^^^^^^^^^^^^^^^^^
file:///var/folders/tr/3tvv8zcd4q302zs0bgbs1h240000gn/T/flutter_test_listener.652XY4/listener.dart:19:27: Error: Method not found: 'serializeSuite'.
StreamChannel channel = serializeSuite(() {
^^^^^^^^^^^^^^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:285:12: Error: A value of type '#lib1::_MatchesGoldenFile' can't be assigned to a variable of type 'invalid-type'.
Try changing the type of the left hand side, or casting the right hand side to 'invalid-type'.
return _MatchesGoldenFile(key);
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:287:31: Error: A value of type '#lib1::_MatchesGoldenFile' can't be assigned to a variable of type 'invalid-type'.
Try changing the type of the left hand side, or casting the right hand side to 'invalid-type'.
return _MatchesGoldenFile.forStringPath(key);
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:325:10: Error: A value of type '#lib1::_MatchesReferenceImage' can't be assigned to a variable of type 'invalid-type'.
Try changing the type of the left hand side, or casting the right hand side to 'invalid-type'.
return _MatchesReferenceImage(image);
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:531:10: Error: A value of type '#lib1::_MatchesAccessibilityGuideline' can't be assigned to a variable of type 'invalid-type'.
Try changing the type of the left hand side, or casting the right hand side to 'invalid-type'.
return _MatchesAccessibilityGuideline(guideline);
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:539:10: Error: A value of type '#lib1::_DoesNotMatchAccessibilityGuideline' can't be assigned to a variable of type 'invalid-type'.
Try changing the type of the left hand side, or casting the right hand side to 'invalid-type'.
return _DoesNotMatchAccessibilityGuideline(guideline);
^
00:07 +0 -1: loading /Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart [E]
Failed to load "/Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart":
Compilation failed
Test: /Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart
Shell: /Users/johanh/flutter/bin/cache/artifacts/engine/darwin-x64/flutter_tester
00:07 +0 -1: Some tests failed.
我基本上清空了 widget_test.dart 以防测试出现问题:
import 'package:flutter_test/flutter_test.dart';
import 'package:cfmobile/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {});
}
flutter doctor -v
:
[✓] Flutter (Channel beta, v0.9.4, on Mac OS X 10.13.6 17G65, locale sv-SE)
• Flutter version 0.9.4 at /Users/johanh/flutter
• Framework revision f37c235c32 (6 weeks ago), 2018-09-25 17:45:40 -0400
• Engine revision 74625aed32
• Dart version 2.1.0-dev.5.0.flutter-a2eb050044
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/johanh/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.4.1, Build version 9F2000
• ios-deploy 2.0.0
• CocoaPods version 1.5.2
[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] VS Code (version 1.28.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.20.0
[✓] Connected devices (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 5.1.1 (API 22) (emulator)
• No issues found!
我试过的:
- 我启动了一个全新的应用程序
flutter create
,完全没有改变,在应用程序内部运行测试。同样的错误。 - 认为我的 SDK 以某种方式损坏,我再次下载了它。
flutter clean
请注意,应用程序本身运行良好。只是测试不断崩溃。
可能与我在运行时经常收到有关版本冲突的错误消息有关flutter packages get
:
Running "flutter packages get" in cfmobile...
Because every version of flutter_test from sdk depends on http 0.11.3+17 and graphql_flutter 1.0.0-alpha.11 depends on http ^0.12.0, flutter_test from sdk is incompatible with graphql_flutter 1.0.0-alpha.11.
And because no versions of graphql_flutter match >1.0.0-alpha.11 <2.0.0, flutter_test from sdk is incompatible with graphql_flutter ^1.0.0-alpha.11.
So, because cfmobile depends on both graphql_flutter ^1.0.0-alpha.11 and flutter_test any from sdk, version solving failed.
pub get failed (1)
我已经通过运行解决了这个问题flutter update-packages --force-upgrade
,这有助于解决这个问题,但随后出现了崩溃。
我用谷歌搜索了这个,什么也没找到。任何帮助将不胜感激。