Flutter I can't build apk with build apk command - flutter

I build an app and trying to build apk. But the apk that I build with flutter build apk command is not working. There is a white screen coming. Today I connect my device with USB and I build it into my device in that way. This time it worked. What I have to do? What am I doing wrong? Is it can be cause of null safety or something else.
flutter doctor -v
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.19044.1889], locale tr-TR)
• Flutter version 3.0.5 at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f1875d570e (5 weeks ago), 2022-07-13 11:24:16 -0700
• Engine revision e85ea0e79c
• Dart version 2.17.6
• DevTools version 2.12.2
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at C:\Users\SEZEN\AppData\Local\Android\sdk
• Platform android-33, build-tools 32.1.0-rc1
• Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.3)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.11.31702.278
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.1)
• Android Studio at C:\Program Files\Android\Android Studio1
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
[√] VS Code (version 1.70.1)
• VS Code at C:\Users\SEZEN\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.46.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1889]
• Chrome (web) • chrome • web-javascript • Google Chrome 104.0.5112.81
• Edge (web) • edge • web-javascript • Microsoft Edge 104.0.1293.54
! Device emulator-5554 is offline.
[√] HTTP Host Availability
• All required HTTP hosts are ava
ilable

Run following command in your terminale and see error log in your console.
flutter run --release

Related

Flutter desktop application reports high CPU usage when run in release mode

My flutter application is consuming CPU at a very high percentage near 80% when run in release mode
Where as in debug mode it is only around 20%.
Anyone help me how to fix this issue for release mode and run application with less CPU usage.
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
[√] Flutter (Channel stable, 3.0.5, on Microsoft Windows [Version 10.0.19044.1889], locale en-PK)
• Flutter version 3.0.5 at C:\SDK\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f1875d570e (5 weeks ago), 2022-07-13 11:24:16 -0700
• Engine revision e85ea0e79c
• Dart version 2.17.6
• DevTools version 2.12.2
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at C:\Users\AppData\Local\Android\sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.9)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.11.32106.194
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1889]
• Chrome (web) • chrome • web-javascript • Google Chrome 104.0.5112.81
• Edge (web) • edge • web-javascript • Microsoft Edge 104.0.1293.54
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!

CMake Error at CMakeLists.txt:3 (project): No CMAKE_CXX_COMPILER could be found. flutter desktop

Iam trying to build a flutter desktop application .
i followed the configuration here
https://docs.flutter.dev/desktop
i installed visual studio 2022 with and add Desktop development with C++ to it .
but when i tried to run a run a desktop application it said
CMake Error at CMakeLists.txt:3 (project):
No CMAKE_CXX_COMPILER could be found.
Exception: Unable to generate build files
here is my flutter doctor
[√] Flutter (Channel master, 3.1.0-0.0.pre.1111, on Microsoft Windows [Version 10.0.19043.1706], locale en-US)
• Flutter version 3.1.0-0.0.pre.1111 at E:\softwares\flutter\flutter_windows_2.0.5-stable\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 52c47e96a3 (7 days ago), 2022-06-05 08:03:02 -0400
• Engine revision 075947bf4d
• Dart version 2.18.0 (build 2.18.0-170.0.dev)
• DevTools version 2.14.0
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc3)
• Android SDK at C:\Users\zamzam107019\AppData\Local\Android\sdk
• Platform android-31, build-tools 31.0.0-rc3
• Java binary at: E:\softwares\flutter\android studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.2.3)
• Visual Studio at E:\vs community
• Visual Studio Community 2022 version 17.2.32526.322
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.2)
• Android Studio at E:\softwares\flutter\android studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1706]
• Chrome (web) • chrome • web-javascript • Google Chrome 102.0.5005.63
• Edge (web) • edge • web-javascript • Microsoft Edge 102.0.1245.39
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
and this is the cmake line that cause the error
# Project-level configuration.
cmake_minimum_required(VERSION 3.14)
project(truck_scale LANGUAGES CXX) <---
i tried too many solution but no thing succeeded
It solved when i modified Desktop development with C++ and installed Windows 10 SDK 10.0.20348.0 instead of 10.0.19041.0

I got Flutter Build time and runtime error - Execution failed for task ':background_locator:compileDebugKotlin'

I got Flutter Build time and runtime error - Execution failed for task ':background_locator:compileDebugKotlin'.
when i try to run the app i got error as below, please help me.
Please can anyone help me to how i solve this problem.
below is my flutter doctor -v output.
PS D:__> flutter doctor -v
[√] Flutter (Channel stable, 3.0.1, on Microsoft Windows [Version 10.0.19044.1706], locale en-IN)
• Flutter version 3.0.1 at D:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision fb57da5f94 (8 days ago), 2022-05-19 15:50:29 -0700
• Engine revision caaafc5604
• Dart version 2.17.1
• DevTools version 2.12.2
Checking Android licenses is taking an unexpectedly long time...[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at C:\Users\Dev_Flutter\AppData\Local\Android\sdk
• Platform android-32, build-tools 31.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.1.32210.238
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[√] VS Code (version 1.67.2)
• VS Code at C:\Users\Dev_Flutter\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.40.0
[√] Connected device (4 available)
• CPH2127 (mobile) • 1cb8d2b1 • android-arm64 • Android 11 (API 30)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1706]
• Chrome (web) • chrome • web-javascript • Google Chrome 101.0.4951.67
• Edge (web) • edge • web-javascript • Microsoft Edge 101.0.1210.39
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Try This command in your project directory:
Flutter Pub Upgrade
There may be an inconsistency between your imported package and the flutter version you're using. this command will upgrade your packages to the latest feasible version.
Also, Please Provide your Flutter doctor output which is helpful to find a solution.

Why I can't find Chrome as a debug target?

As you can see, there is only Windows debug.
I removed android and ios folders so it is not strange not to see them, but it's strange that I can't see Chrome.
Why there is only Windows (desktop)? Any way to debug with Chrome (or Edge)?
flutter doctor -v
[√] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.22000.675], locale ja-JP)
• Flutter version 2.10.5 at C:\Flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5464c5bac7 (4 weeks ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at C:\Users\yukik.000\AppData\Local\Android\sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.11.11)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.11.32228.343
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[√] VS Code (version 1.67.1)
• VS Code at C:\Users\yukik.000\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.40.0
[√] Connected device (1 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.675]
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Wasn't [√] Chrome installed here before?
Try to run below command if your project is not web enabled or not Web folder inside your project
flutter config --enable-web
Then restart VsCode and run your project with available device Chrome or Edge.

How do I get hot Reload to work with flutter?

I have tried just about everything. Uninstalled the flutter plug in, made sure my path was right. Ran flutter doctor and everything is fine. Ran flutter clean up.
Even tried switching to windows beta.
Can't do a hot Reload when I run in windows app but I can do it when I run it for chrome.
Using Android Studio bumblebee which I have also reinstalled.
Any other advice?
Added my flutter doctor -v
[√] Flutter (Channel beta, 2.11.0-0.1.pre, on Microsoft Windows [Version 10.0.19042.1526], locale en-US)
• Flutter version 2.11.0-0.1.pre at C:\Users\pluca\Documents\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision b101bfe32f (7 days ago), 2022-02-16 07:36:54 -0800
• Engine revision e355993572
• Dart version 2.17.0 (build 2.17.0-69.2.beta)
• DevTools version 2.10.0-dev.1
[√] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at C:\Users\pluca\AppData\Local\Android\sdk
• Platform android-32, build-tools 32.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.1.32210.238
• Windows 10 SDK version 10.0.19041.0
[√] Android Studio (version 2021.1)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822)
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19042.1526]
• Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.102
• Edge (web) • edge • web-javascript • Microsoft Edge 98.0.1108.56
[√] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
I figured it out! I was running Visual Studio 2022. I uninstalled it an installed Visual Studio 2019.
Now it works!!!