How to clean your build with Flutter RP2 in Androi

2020-08-22 07:02发布

问题:

With the release of FLutter Release Preview 2 using Android Studio 3.1.4 my project has sporadic build issues when I stop the program from Android Studio with the command stop 'main.dart' (command f2) and then do a run 'main.dart' (^R) I get the error listed below. Yet if I totally close Android Studio and open the project again, it compiles and runs correctly without the error. I'm wondering if there is a way to clean the project to elevate having to close and open Android Studio, this is sort of counter productive to Flutter hot reload.

Here's the Android Studio error that I get:

Launching lib/main.dart on Android SDK built for x86 in debug mode... [{"event":"app.progress","params":{"appId":"04e99281-55ea-41cd-851f-5b07487c5302","id":"0","progressId":null,"message":"Initializing gradle..."}}]Initializing gradle...

Resolving dependencies... Running 'gradlew assembleDebug'... registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) compiler message: lib/ui/loginScreen.dart:1:1: Error: Can't access platform private library. compiler message: import 'dart:_http'; compiler message: ^ Compiler failed on /Users/pbirdsall/Documents/highline/hl_leverage/lib/main.dart

FAILURE: Build failed with an exception.

  • Where: Script '/Users/pbirdsall/flutter/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 460

  • What went wrong: Execution failed for task ':app:flutterBuildDebug'.

    Process 'command '/Users/pbirdsall/flutter/flutter/bin/flutter'' 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.

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

BUILD FAILED in 8s Finished with error: Gradle build failed: 1

You can ignore the following part of the error log (in italics above), as this occurs on a successful execution of the program.

deprecated, use registerGeneratedFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) registerResGeneratingTask is deprecated, use registerGeneratedFolders(FileCollection) compiler message: lib/ui/loginScreen.dart:1:1: Error: Can't access platform private library. compiler message: import 'dart:_http'; compiler message: ^ Compiler failed on

My version of Android Studio is 3.1.4

My version of Flutter is:

Flutter 0.8.2 • channel beta • https://github.com/flutter/flutter.git Framework • revision 5ab9e70727 (2 weeks ago) • 2018-09-07 12:33:05 -0700 Engine • revision 58a1894a1c Tools • Dart 2.1.0-dev.3.1.flutter-760a9690c2

I'm running on macOS High Sierra 10.13.6

回答1:

Menu Tool > Flutter > Flutter Clean

or in a terminal window in the project directory

flutter clean