╔════════════════════════════════════════════════════════════════════════════╗ ║ Welcome to Flutter! - https://flutter.dev ║ ║ ║ ║ The Flutter tool uses Google Analytics to anonymously report feature usage ║ ║ statistics and basic crash reports. This data is used to help improve ║ ║ Flutter tools over time. ║ ║ ║ ║ Flutter tool analytics are not sent on the very first run. To disable ║ ║ reporting, type'flutter config --no-analytics'. To display the current ║ ║ setting, type'flutter config'. If you opt out of analytics, an opt-out ║ ║ event will be sent, and then no further information will be sent by the ║ ║ Flutter tool. ║ ║ ║ ║ By downloading the Flutter SDK, you agree to the Google Terms of Service. ║ ║ Note: The Google Privacy Policy describes how data is handled in this ║ ║ service. ║ ║ ║ ║ Moreover, Flutter includes the Dart SDK, which may send usage metrics and ║ ║ crash reports to Google. ║ ║ ║ ║ Read about data we send with crash reports: ║ ║ https://flutter.dev/docs/reference/crash-reporting ║ ║ ║ ║ See Google s privacy policy: ║ ║ https://policies.google.com/privacy ║ ╚════════════════════════════════════════════════════════════════════════════╝
[✗] Windows Version (Unable to confirm if installed Windows version is 10 or greater)
[✗] Android toolchain - develop for Android devices ✗ Unable to locate Android SDK. Install Android Studio from: https://developer.android.com/studio/index.html On first launch it will assist you in installing the Android SDK components. (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions). If the Android SDK has been installed to a custom location, please use `flutter config --android-sdk` to update to that location.
[✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✗] Visual Studio - develop for Windows ✗ Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components
[!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
[✓] VS Code, 64-bit edition (version 1.74.3) • VS Code at C:\Program Files\Microsoft VS Code • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [版本 10.0.22621.1194] • Edge (web) • edge • web-javascript • Microsoft Edge 109.0.1518.70
[✓] HTTP Host Availability • All required HTTP hosts are available
All done! You can find general documentation for Flutter at: https://docs.flutter.dev/ Detailed API documentation is available at: https://api.flutter.dev/ If you prefer video documentation, consider: https://www.youtube.com/c/flutterdev
In order to run your application, type:
$ cd demo_app $ flutter run
Your application code is in demo_app\lib\main.dart.
PS D:\sources\flutter_repos> cd .\demo_app\ PS D:\sources\flutter_repos\demo_app>
使用命令运行 Flutter 项目: flutter run,
1 2 3 4 5 6 7 8
PS D:\sources\flutter_repos\demo_app> flutter run Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! Multiple devices found: Windows (desktop) • windows • windows-x64 • Microsoft Windows [版本 10.0.22621.1194] Edge (web) • edge • web-javascript • Microsoft Edge 109.0.1518.70 [1]: Windows (windows) [2]: Edge (edge) Please choose one (To quit, press "q/Q"):
PS D:\sources\flutter_repos> flutter doctor -v Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! [✓] Flutter (Channel stable, 3.19.0, on Microsoft Windows [版本 10.0.22631.3155], locale zh-CN) • Flutter version 3.19.0 on channel stable at D:\AppData\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision bae5e49bc2 (2 days ago), 2024-02-13 17:46:18 -0800 • Engine revision 04817c99c9 • Dart version 3.3.0 • DevTools version 2.31.1
[✗] Windows Version (Unable to confirm if installed Windows version is 10 or greater)
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at D:\AppData\Android\Sdk • Platform android-34, build-tools 30.0.3 • ANDROID_HOME = D:\AppData\Android\Sdk • Java binary at: D:\AppData\openjdk17.0.2\bin\java • Java version OpenJDK Runtime Environment (build 17.0.2+8-86) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✗] Visual Studio - develop for Windows ✗ Visual Studio not installed; this is necessary for Windows development. Download at https://visualstudio.microsoft.com/downloads/. Please install the "Desktop development with C++" workload, including all of its default components
[!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions).
[✓] VS Code, 64-bit edition (version 1.74.3) • VS Code at C:\Program Files\Microsoft VS Code • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (2 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [版本 10.0.22621.1194] • Edge (web) • edge • web-javascript • Microsoft Edge 109.0.1518.70
[✓] HTTP Host Availability • All required HTTP hosts are available
! Doctor found issues in 5 categories.
之前显示为红色 [✗] 的 Android toolchain 现在已经变成了黄色的 [!]
1 2 3 4 5 6 7 8
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at D:\AppData\Android\Sdk • Platform android-34, build-tools 30.0.3 • ANDROID_HOME = D:\AppData\Android\Sdk • Java binary at: D:\AppData\openjdk17.0.2\bin\java • Java version OpenJDK Runtime Environment (build 17.0.2+8-86) ! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
该项最后一行提示, 需要运行命令并同意 Android 的协议, 在控制台窗口输入命令: flutter doctor --android-licenses, 全部提问回答: y, 命令执行过程如下:
1 2 3 4 5 6 7 8 9
PS D:\sources\flutter_repos> flutter doctor --android-licenses Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! [=======================================] 100% Computing updates... 6 of 7 SDK package licenses not accepted. Review licenses that have not been accepted (y/N)? y
1/6: License android-googletv-license:
<总共`6项`协议,内容很长, 要输入`6`次 `y`, 过程省略>
同意协议后再次检测Flutter运行环境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
PS D:\sources\flutter_repos> flutter doctor -v Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! [✓] Flutter (Channel stable, 3.19.0, on Microsoft Windows [版本 10.0.22631.3155], locale zh-CN) • Flutter version 3.19.0 on channel stable at D:\AppData\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision bae5e49bc2 (2 days ago), 2024-02-13 17:46:18 -0800 • Engine revision 04817c99c9 • Dart version 3.3.0 • DevTools version 2.31.1
[✗] Windows Version (Unable to confirm if installed Windows version is 10 or greater)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at D:\AppData\Android\Sdk • Platform android-34, build-tools 30.0.3 • ANDROID_HOME = D:\AppData\Android\Sdk • Java binary at: D:\AppData\openjdk17.0.2\bin\java • Java version OpenJDK Runtime Environment (build 17.0.2+8-86) • All Android licenses accepted.
检测结果显示 Android toolchain 已经没有问题。
使用模拟器
Flutter 项目 运行时使用的 Android 模拟器 与 Android 项目 开发时是一样的, 可以使用 Android Studio 自带的模拟器, 也可以使用其他第三方的模拟器。Android Studio 自带模拟器的安装和使用在此不再做说明。这里选择的第三方模拟器是 雷电模拟器 或 夜神模拟器, 其他的第三方模拟器使用方法类似。
因为不使用 Android Studio 进行 Flutter 项目开发, 启动 Android Studio 自带的模拟器很不方便, 所以选择使用其他第三方的Android 模拟器
PS D:\sources\flutter_repos\demo_app> flutter run Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! Launching lib\main.dart on SM G955N in debug mode... Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! Running Gradle task 'assembleDebug'... 736.7s ✓ Built build\app\outputs\flutter-apk\app-debug.apk. Installing build\app\outputs\flutter-apk\app-debug.apk... 4.2s Syncing files to device SM G955N... 111ms
Flutter run key commands. r Hot reload. 🔥🔥🔥 R Hot restart. h List all available interactive commands. d Detach (terminate "flutter run" but leave application running). c Clear the screen q Quit (terminate the application on the device).
💪 Running with sound null safety 💪
An Observatory debugger and profiler on SM G955N is available at: http://127.0.0.1:51335/UEbv3xKoFAk=/ E/libEGL ( 3429): called unimplemented OpenGL ES API The Flutter DevTools debugger and profiler on SM G955N is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:51335/UEbv3xKoFAk=/
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! Launching lib\main.dart on TAS AL00 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':gradle:compileGroovy'. > Could not resolve all files for configuration ':gradle:compileClasspath'. > Could not resolve com.squareup:javawriter:2.5.0. Required by: project :gradle > com.android.tools.build:gradle:7.3.0 > com.android.tools.build:builder:7.3.0 > Could not resolve com.squareup:javawriter:2.5.0. > Could not get resource 'https://repo.maven.apache.org/maven2/com/squareup/javawriter/2.5.0/javawriter-2.5.0.pom'. > Could not GET 'https://repo.maven.apache.org/maven2/com/squareup/javawriter/2.5.0/javawriter-2.5.0.pom'. > Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.112.215] failed: Connection timed out: no further information > Could not resolve org.ow2.asm:asm:9.1. Required by: project :gradle > com.android.tools.build:gradle:7.3.0 > com.android.tools.build:gradle-api:7.3.0 > Could not resolve org.ow2.asm:asm:9.1. > Could not get resource 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm/9.1/asm-9.1.pom'. > Could not GET 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm/9.1/asm-9.1.pom'. > Connect to repo.maven.apache.org:443 [repo.maven.apache.org/146.75.112.215] failed: Connection timed out: no further information
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 3m 17s [!] Gradle threw an error while downloading artifacts from the network. Retrying Gradle Build: #1, wait time: 100ms
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':gradle:compileGroovy'. > Could not resolve all files for configuration ':gradle:compileClasspath'. > Could not resolve com.squareup:javawriter:2.5.0. Required by: project :gradle > com.android.tools.build:gradle:7.3.0 > com.android.tools.build:builder:7.3.0 > Could not resolve com.squareup:javawriter:2.5.0. > Could not get resource 'https://repo.maven.apache.org/maven2/com/squareup/javawriter/2.5.0/javawriter-2.5.0.pom'. > Could not GET 'https://repo.maven.apache.org/maven2/com/squareup/javawriter/2.5.0/javawriter-2.5.0.pom'. > Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.108.215] failed: Connection timed out: no further information > Could not resolve org.ow2.asm:asm:9.1. Required by: project :gradle > com.android.tools.build:gradle:7.3.0 > com.android.tools.build:gradle-api:7.3.0 > Could not resolve org.ow2.asm:asm:9.1. > Could not get resource 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm/9.1/asm-9.1.pom'. > Could not GET 'https://repo.maven.apache.org/maven2/org/ow2/asm/asm/9.1/asm-9.1.pom'. > Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.108.215] failed: Connection timed out: no further information
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 2m 13s [!] Gradle threw an error while downloading artifacts from the network. Exception: Gradle task assembleDebug failed with exit code 1
PS D:\sources\flutter_repos\demo_app> flutter run Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source! Using hardware rendering with device Android SDK built for x86 64. If you notice graphics artifacts, consider enabling software rendering with "--enable-software-rendering". Launching lib/main.dart on Android SDK built for x86 64 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong: Execution failed for task ':app:compileDebugKotlin'. > Could not resolve all dependencies for configuration ':app:kotlinCompilerClasspath'. > Could not load module metadata from /home/laohoo/.gradle/caches/modules-2/metadata-2.97/descriptors/org.jetbrains.kotlin/kotlin-script-runtime/1.6.10/a8be1fe3b3911d3d3425fe720cf42835/descriptor.bin
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s Running Gradle task 'assembleDebug'... 2,548ms Exception: Gradle task assembleDebug failed with exit code 1