How do you compile a flutter application? - flutter

I'm seeing that I can introduce a compilation error in my dart code but flutter build ios will still successfully run. If I flutter run -d [my-simulator] the compile error will immediately be presented in a red screen on the simulator but I can't currently easily do this in a CI type check.
Is there are cli command I can run to ensure that all of the dart code is free of compile errors?

You can run dart analyze or flutter analyze commands.
More info

Related

I am having a problem building a Flutter App

I has a build a flutter app before successfully, but I try to update the code of my flutter app because I discovered some bugs but when j try to build it I get a error about error configuring video_player Android, I try to add it as a Dependencies but still it didn't work, I also invalidate cache's too it didn't work because it also said something about Cache's, I also upgraded my flutter SDK, still it didn't work, I will attach a image under this write up.
The error I am facing 😭😪
The error I am facing 😭😪
Write below command in terminal to clear cache with android project path.
flutter pub cache clean
./gradlew clean
gradlew cleanBuildCache

Flutter gives "FlutterFirebaseAnalyticsPlugin.java uses unchecked or unsafe operations" error when I try to run without debugging

When I try running my app without debugging. The app gives me the following error and proceeds with the installation(I'm using my phone via USB Debugging to test my app).
Launching lib\main.dart on vivo 1901 in debug mode...
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_analytics-9.1.10\android\src\main\java\io\flutter\plugins\firebase\analytics\FlutterFirebaseAnalyticsPlugin.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
√ Built build\app\outputs\flutter-apk\app-debug.apk.
And when I enter my registered details(I have already created an account on my app) on the login page and click login , it gives me an authentication error.
The error is caused due to outdated packages in your flutter project.
To solve the errors, do the following :
Step 1: Run the command flutter pub outdated in the terminal of your development environment. This command will find and display the list of packages that can be updated.
Step 2: Run the command flutter pub upgrade in the terminal of your development environment. This command will update the outdated packages.

seems no-sound-null-safety parameter not work in flutter 2.2.1

I am upgrade my flutter to version 2.2.1, but it seems --no-sound-null-safety no longer avaliable when build the ios package. I am build the project using this command:
~/apps/flutter/bin/flutter build ios --release --no-codesign --no-sound-null-safety
but the output still tell me some package did not support null safety:
Changing current working directory to: /Users/dolphin/source/cruise-open
Warning: Building for device with codesigning disabled. You will have to manually codesign before deploying to device.
Building com.earth.dolphin for device (ios-release)...
Running Xcode build...
Xcode build done. 36.6s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
2 warnings generated.
2 warnings generated.
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
- package:state_notifier
- package:fish_redux
- package:flutter_icons
For solutions, see https://dart.dev/go/unsound-null-safety
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Building targets in parallel
note: Planning build
note: Analyzing workspace
note: Constructing build description
note: Build preparation complete
note: Removed stale file
Encountered error while building for device.
is there any solution with this problem? I am search from flutter issue but no one confirm this problem(https://github.com/flutter/flutter/issues/84199), is it a bug of new version?(Because I am using this command works fine until I upgrade to version 2.2.1). is there other way to pass no-sound-null-safety parameter? I have tried many version and found some version works fine, some version did not works. Maybe a flutter bug.
flutter 2.0.1 works
flutter 2.0.3 works
flutter 2.0.6 works
flutter 2.2.0 not works
flutter 2.2.1 not works
flutter 2.2.2 not works
flutter 2.2.3 not works
seem a bug, will fixed next release:https://github.com/flutter/flutter/pull/84372

Flutter - Could not find a command named "-"

I'm new to flutter, when I created a new project of flutter and run it, this appears :
Using hardware rendering with device AOSP on IA Emulator. If you notice graphics artifacts,
consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Could not find a command named "-".
Usage: dart [<vm-flags>] <command|dart-file> [<arguments>]
Global options:
-h, --help Print this usage information.
-v, --verbose Show additional command output.
--version Print the Dart SDK version.
--enable-analytics Enable anonymous analytics.
--disable-analytics Disable anonymous analytics.
Available commands:
analyze Analyze the project's Dart code.
compile Compile Dart to various formats.
create Create a new project.
fix Apply automated fixes to Dart source code.
format Idiomatically format Dart source code.
migrate Perform a null safety migration on a project or package.
pub Work with packages.
run Run a Dart program.
test Run tests in this package.
Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 510ms
Exception: Gradle task assembleDebug failed with exit code 64
I'm stuck with this problem, how to solve this?
I have solved this problem. I run this project in my D: directory while my flutter and android SDK was installed in C: directory. So, when I tried to create flutter project in C:, it worked. But, I still can't configure why this problem happened.
#Papskipapap may I ask, if running your project on D: also inculded some path name which contained a "-" (dash) in it? As a rule of thumb: Keep pathnames easy, i.e. without blanks or special characters other than "_" (underscore), many tools just can not handle those...

Flutter crash on release apk installed on devices / Emulator

Could you guys please help me with the problems I currently have?
I'm trying to follow the steps of how to release apk android from: https://flutter.dev/docs/deployment/android, The program which I tried to release is only the NewFlutterApplication which created from template of Flutter
The problem is: Have been followed all the steps, still I can't run the release apk which i build from flutter
The Error which I got:
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install E:\FlutterProject\flutter_app_1\build\app\outputs\apk\app.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]
Install failed
The things that I have tried:
Tried from this site Flutter release apk is not installing on device, but there is no hope
Tried from this site Can't build release APK for flutter, but still no hope
Tried using the flutter run --release in the real device, it's directly crash and return stopped working
Tried using the flutter build apk && flutter install, it's not running and give the error from top error
Tried using flutter run -v it don't give any error and run smoothly and the debug it's still run smoothly, only the release APK is the problem which can't be run
UPD: This answer is outdated, Flutter now supports x86/x64
You can't run release build on emulator, because currently flutter doesn't support x86 release binaries
See this issue, and put thumb up reaction on it to increase priority:
https://github.com/flutter/flutter/issues/9253
This issue also affects devices that use Intel Atom and some Chromebooks, but don't worry, they will be excluded from supported devices by Google Play automatically
INSTALL_FAILED_NO_MATCHING_ABIS is when you are trying to install an app that has native libraries and it doesn't have a native library for your cpu architecture. For example if you compiled an app for armv7 and are trying to install it on an emulator that uses the Intel architecture instead it will not work.