Flutter on a MacBook M1: Unable to get flutterfire_cli to work while setting up a Web App - flutter

I'm VERY new to the Mac OS (I'm running macOS Monterey v12.4) on an M1 Macbook Pro.
I have Flutter installed and have built a few sandbox apps with this framework.
I'm trying to build a web application with Flutter and Cloud Firestore and thought it best to use the flutterfire_cli to do some of the configurations but I'm stuck trying to run a specific setup command.
The command that I'm trying to run is "dart pub global activate flutterfire_cli" from a terminal. The output that I get is the following when I run this (the error is at the bottom):
ansi_styles 0.3.2+1s...
args 2.3.1
async 2.9.0
ci 0.1.0
cli_util 0.3.5
collection 1.16.0
dart_console 1.0.0
deep_pick 0.10.0
ffi 1.2.1 (2.0.0 available)
file 6.1.2
flutterfire_cli 0.2.2+2
http 0.13.4
http_parser 4.0.1
interact 2.1.1
json_annotation 4.5.0
matcher 0.12.11
meta 1.8.0
path 1.8.2
petitparser 5.0.0
platform 3.1.0
process 4.2.4
pub_semver 2.1.1
pub_updater 0.2.2
pubspec 2.2.0
quiver 3.1.0
source_span 1.9.0
stack_trace 1.10.0
string_scanner 1.1.1
term_glyph 1.2.0
tint 2.0.0
typed_data 1.3.1
uri 1.0.0
win32 2.6.1 (2.7.0 available)
xml 5.4.1 (6.1.0 available)
yaml 3.1.1
Could not find a file named "pubspec.yaml" in "/Users/myusername/.pub-cache/hosted/pub.dartlang.org/flutterfire_cli-0.2.2+2".
When I try to run the next command according to the documentation here: https://firebase.google.com/docs/flutter/setup?platform=web
That command is "flutterfire configure" from within Android studio
I get the following error: "zsh: command not found: flutterfire"
I'm running node version "v16.15.1" and nvm version "0.39.1" with npm version "8.12.1"
Has anyone run into this?
Thanks!

In your termianl run:
export PATH="$PATH":"$HOME/.pub-cache/bin"
Then try to use flutterfire command in your project directory.

Thanks for that response shuster.
I'm afraid that my environment needed abit more help as there were errors when running several commands. I'll outline the steps I used below to finally get this working.
Steps to resolve the issue
Delete Node and NPM (aka - fresh start)
This post here outlined a straightforward way to do this: https://www.positronx.io/how-to-uninstall-node-js-and-npm-from-macos/
Reinstall node WITHOUT using the 'sudo' command using NVM
Verify that all versions are in place and working for NVM, NODE and NPM - all good
Was still getting issues with the command from Dart to activate the flutterfire_cli "dart pub global activate flutterfire_cli"
I didn't capture the exact error, but there was a complaint about a PUBSPEC.YAML missing
I suspected that something was wrong with my Dart installation or cache, so I decided to try clearing the cache
Repairing the cache using this command "dart pub cache repair" produced a "permissions denied" error on the .pub-cache folder
Cleaning the DART cache using this command "dart pub cache clean" produced the same "permissions denied" error on the same folder
So, I went in and deleted everything in that .pub-cache folder manually
I then went back to the terminal and ran the command "dart pub global activate flutterfire_cli" to try and get Dart into a better place
This worked but I got an error message (basically) stating that the path was wrong for a global command and I needed to run "export PATH="$PATH":"$HOME/.pub-cache/bin"
If I ran that PATH command from the terminal, then the Flutterfire CLI would work for that session only but not work in my IDE (Android Studio) unless I ran that same command again inside the IDE
At this point I knew I was very close and needed to figure out how to get this Mac to keep that setting all the time
After some digging into what this "zsh" thing was, I found a post that explained it very well and was able to make the change permanent https://wpbeaches.com/how-to-add-to-the-shell-path-in-macos-using-terminal/
 
Hope this helps someone - happy coding!

Related

fvm keep requesting change flutter path

I am trying to use fvm on Windows.
Because my projects use mixed of languages, I need to change the version globally.
The problem is that it keeps asking me to change the flutter path.
At first,
So, I moved flutter path down to the bottom of fvm\default\bin.
Here is how I setup the path.
Now, if I change global flutter version again, the path is changed as the version of fvm, not the default... which is not in the path at all.
If it is just the message, I can ignore, but when I try to open up my project and try flutter --version the global version is not changed.
Can anybody guess what is the problem?
I did install with flutter pub global activate fvm.
I tried deactivate and activate again, removed reset the path in various ways, but keep getting same issue.
Another thing is I am keep getting Can't load Kernel binary: Invalid SDK hash message. I just assume this is kind of related to the first issue, but not of it.
Thanks.
I guess I solved this issue.
First of all, I had flutter installed version 1.22.6 at the beginning. and installed fvm with flutter pub global activate fvm. Then, the fvm version 1.3.7 installed. If I try to install flutter version 3.x.x, it fails with message like Internal Error: Could not infer Flutter Version 3.x.x or fvm version 1.3.7 doesn't support ~~~ something like that. So, I upgraded the actual flutter installed to the latest version, and also upgraded fvm to the latest version. Then, it never go back to 1.22.6 globally with the fvm.
So, I reinstalled the flutter version 1.22.6, complete uninstall fvm by flutter pub global deactivate fvm and also deleting fvm folder.(if you don't delete the folder and reinstall, it will install the same version of fvm you previously installed) And reinstall with flutter pub global activate fvm. Then, it will then install fvm 1.3.7 version. With this version of fvm, I couldn't install 3.0.2, but could install stable
but using different commands for this fvm 1.3.7 version.... like fvm use stable --global... you can find some commands here
it was because of the actual flutter version installed and fvm version I guess.... Please comment below if I was wrong.

Failed to start DevTools: Dart DevTools exited with code 255

I am getting this error code in my Visual Studio Code. How can I fix it?
I am using Flutter v2.5.3.
You can try fixing it by running this in the terminal:
Just copy and paste the below code into the terminal and run it.
dart pub global activate devtools -v 2.8.0
which downgrades the version to 2.8.0 (that works fine). I found the answer on GitHub.
I agree with RandomCoder's answer to avoid executing command
dart pub global activate devtools -v 2.8.0
every time before opening Visual Studio Code.
And also if you didn't know the location of the build folder mentioned by RandomCoder, I found the location after reading it here for the pub cache folder:
By default, this directory is located under . pub-cache in your home directory (on macOS and Linux), or in %LOCALAPPDATA%\Pub\Cache (on Windows). (The precise location of the cache may vary depending on the Windows version.)
After you found it, go to the \hosted\pub.dartlang.org\devtools-2.8.0 directory to copy the build version there and paste it in \hosted\pub.dartlang.org\devtools-2.9.2.
I still didn't know if there is any bad effects of copy pasting it to a newer version folder, but in my case it's working until now.
In my case there wasn’t any build folder in the devtools-2.9.2 folder.
I copied it from 2.8.0 and it now works.
For Android Studio
Close Android Studio
Rn dart pub global activate devtools -v 2.8.0 to downgrade (as suggested in a previous answer)
Open Android Studio
Run your build
For Visual Studio Code
Open Terminal
Run dart pub global activate devtools -v 2.8.0 to downgrade (as suggested a previous answer)
I fix this by:
flutter upgrade
This is an issue coming since yesterday. Maybe they must have updated the Dart engine.
There are two ways which will help you to solve the issue.
Update the Flutter SDK to the latest version and restart your PC:
flutter upgrade
Use the Dart Devtools manually
Run flutter pub global in another terminal. Run devtools and then open http://127.0.0.1:9100
Enter a running application field address of your running application in the Connect: "http://127.0.0.1:60230/J7_wS_YhTuo=/"
You can find this URL in debug console when you run the code.
√ Built build\app\outputs\flutter-apk\app-debug.apk.
Connecting to VM Service at ws://127.0.0.1:51849/mHlycLJYEWw=/ws
If you are getting any issue regarding the port, then do this in your Flutter project console
flutter run --observatory-port=9100
Once the application starts you can see the message in the console.
If you are getting any server issue in the web browser
then enter
dart devtools
In cmd
Downgrade to devtools-2.8.0
And activate using dart pub global activate devtools -v 2.8.0
These two steps worked in my case
First activate your devtool using this command...
flutter pub global activate devtools
flutter pub global run devtools
And after that, try launching it from Visual Studio Code as described in the documentation: Install and run DevTools from VS Code

Flutter Dart on windows 10

When I am running any command that uses dart the response is always as follows;
building flutter tool...
Running Pub upgrade...
The current Dart SDK version is 2.10.0-0.0.dev.flutter-9dca49e71e.
Because flutter_tools depends on collection >=1.15.0-nnbd <1.15.0-nullsafety.2 which requires SDK version >=2.9.0-18.0 <=2.9.10, version solving failed.
I am not able to switch the version nor the channel as those commands run through the same response.
I tried to uninstall flutter and dart, but I have only gotten back to the same issues.
Any help?
Navigate to where to your flutter install directory e.g. C:\Tools\Flutter and do a git pull.
After that you should be able to run any command, such as flutter --help and the Dart SDK will be on the correct version.
This can be verified by running flutter upgrade
I just needed to update my Path ENV Variable

Flutter - Flutter Version Management (fvm) package not working in windows

I just added the the fvm package to switch the flutter channel from stable to master without downloading sdk components every time when switching flutter channels.
I have followed the step written in readme.md for switching the channel.
I have set the following path in my environment variables.
D:\Program_Files\FlutterSDK\SDK\flutter\bin;
D:\Program_Files\FlutterSDK\SDK\dart-sdk\bin;
C:\Users\User\AppData\Roaming\Pub\Cache\bin;
Now, i have opened my first project in which i want to use "flutter SDK's master channel". But, whenever i try to use the command "fvm use master". It's not working.
It is giving me an error like,
'fvm' is not recognized as an internal or external command,
So, can anyone suggest a solution?
Thanks.
try :
pub global run fvm:main
pub global run fvm:main use VERSION
Hi adding in your path:
%LOCALAPPDATA%\Pub\Cache\bin
More info:
https://dart.dev/tools/pub/cmd/pub-global#running-a-script-from-your-path
In my case fvm commands did not work on Windows even tho I checked everything. It gave missing fvm.exe file and other errors. If you also stuck there you can use this way. Only way I managed to get it work is to use longer commands like these:
flutter pub global run fvm:main list
Seems like all fvm commands:
config Set configuration for FVM
flutter Proxies Flutter Commands
install Installs Flutter SDK Version
list Lists installed Flutter SDK Version
releases Lists Flutter SDK releases.
remove Removes Flutter SDK Version
use Which Flutter SDK Version you would like to use
version Prints the currently-installed version of FVM
Works like this, you just need to add the fvm command to the ending of this - flutter pub global run fvm:main. So add any of them like this form:
flutter pub global run fvm:main releases
flutter pub global run fvm:main install 2.2.0
flutter pub global run fvm:main use 2.2.0
are you add "C:\flutter\bin\cache\dart-sdk\bin" to path?
if you in windows you should run your text editor as administrator as following
In my case Error Message was
Usage Error: Flutter version null is not installed
To fix this:
I have activated FVM by pub global activate fvm;
Printed installed fvm list by fvm list, it should give result as the image below:
Selected which Flutter SDK version to use by running fvm use 1.22.0 (in my case 1.22.0, it may differ according to your desired version) command, It will download SDK if it is not installed yet;
Now you can check is flutter running in your project by running flutter;
Also, you can check if the Flutter SDK version set by calling again fvm list.
The tick means, that version is running in your project.

Ionic run / build not working

when execute "ionic run android " nothing happens !!!
No Errors, No Messages - what happens?
I had the same issue, dropping my version of Node to 4.2.1 fixed it.
See: Ionic run does nothing
I thing the steps below can help, at least you can get a better log, to solve your problem:
Make sure you added a platform to your project
$ ionic platform add android
Once you have a platform try to run using cordova
$ cd {YOUR_PROJECT_DIR}/platforms/android/cordova
$./run
i just got in same kind..!
so,just check setup with ionic info command
Your system information:
Cordova CLI: 5.4.1
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic Version: 1.1.0
Ionic CLI Version: 1.7.12
Ionic App Lib Version: 0.6.5
OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.2 LTS
Node Version: v5.4.0
i just upgrade cordova version to 5.4.1
this setup,worked for me..!
fix is here (FOR WINDOWS ONLY)
I am facing the same problem of Build then i finally found out the solution.
SOLUTION
So You must have the Android Api 23 in order for this command to work.
Error of Daemon process will be solve after installing the Api 23 and extra build tools and run command
COMMAND : cordova build android --release
I am sure this fix would help you to solve the problem.
STEPS
1. First check the version of android through this COMMAND:
cordova platform help
2. Run the build command after installing the Api 23 and extra build tools.
3. If Even this not work then Try add the variable in the
Environment variables > System variables >
add _JAVA_OPTIONS and value = -Xmx512M
Then Run cordova build android --release
BUT FIRSTLY SET UP THE ENVIRONMENT VARIABLES
Environment Variable setup Image
android API 23
COPY FROM HERE
ENVIRONMENT VARIABLES:-
USER VARIABLES
PATH
C:\Ruby23\bin;C:\Users\kumar\AppData\Roaming\npm;C:\ANDROID_SDK\tools;%SystemRo
ot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;
SYSTEM VARIABLES
ADD NAME AND VALUE
2.1 _JAVA_OPTIONS -Xmx512M
2.2 ANDROID_HOME C:\ANDROID_SDK
2.3 PATH ->
C:\ProgramFiles\Java\jdk1.8.0_60\bin;C:\ProgramFiles\nodejs;C:\Gradle\gradle-4.0\bin;C:\ANDROID_SDK\tools;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;%SystemRoot%\system32; %SystemRoot%; %SystemRoot%\System32\Wbem;