dwyl / learn-flutter

🦋 Learn how to use Flutter to Build Cross-platform Native Mobile Apps
https://flutter.dev
GNU General Public License v2.0
73 stars 8 forks source link

Flutter Mac Installation #13

Open nelsonic opened 4 years ago

nelsonic commented 4 years ago

While attempting to download/install Flutter following the official instructions: https://flutter.dev/docs/get-started/install/macos

I also had to download:

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-GB)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✗] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS development.
      Download at: https://developer.apple.com/xcode/download/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on
        the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install:
        sudo gem install cocoapods
[!] Android Studio (version 3.5)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[!] VS Code (version 1.41.1)
    ✗ Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[!] Connected device
    ! No devices available

! Doctor found issues in 4 categories.

“Visual Studio Code” can’t be opened because Apple cannot check it for malicious software. image see: https://github.com/microsoft/vscode/issues/74782 (open Settings > Security ... click on "Open Anyway") visual-studio-code-open-anyway

[!] Android Studio (version 3.5) ✗ Flutter plugin not installed; this adds Flutter specific functionality. ✗ Dart plugin not installed; this adds Dart specific functionality. https://stackoverflow.com/questions/51860845/flutter-plugin-not-installed-error-when-running-flutter-doctor

After installing everything we have the following:

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-GB)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)

[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.41.1)
[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

https://stackoverflow.com/questions/49045393/flutter-run-no-connected-devices https://flutter.dev/docs/get-started/install/macos#set-up-the-android-emulator

Open Android Studio and locate the drop-down that says no devices: image Click on "Open AVD Manager" (Android Virtual Device) Screenshot 2020-01-10 at 17 45 29

You should see the following: image

Select the API version: (click the download button) image

That will download Android Q which is another 1.1Gb image

nelsonic commented 4 years ago

Still getting:

[!] Connected device
    ! No devices available

https://stackoverflow.com/questions/44485848/android-sdk-cannot-be-found-by-flutter/51644461#51644461

flutter config --android-sdk /path/to/android/sdk

Had to go searching for these two paths ... https://stackoverflow.com/questions/34532063/finding-android-sdk-on-mac-and-adding-to-path In my case (on Mac)

flutter config --android-sdk ~/Library/Android/sdk
nelsonic commented 4 years ago

Still getting

[!] Connected device
    ! No devices available

Ran:

flutter config --enable-web

Got:

Setting "enable-web" value to "true".

You may need to restart any open editors for them to read new settings.

Restarting my computer ...

nelsonic commented 4 years ago
-bash: flutter: command not found

https://stackoverflow.com/questions/46423088/flutter-run-command-not-working/49727202

export PATH=~/code/flutter/bin:$PATH;

Eventually ... after following: https://developer.android.com/studio/debug/dev-options#enable

[✓] Connected device (1 available)
    • Pixel 3 • 89HX09YMG • android-arm64 • Android 10 (API 29)

• No issues found!
miguelmartins17 commented 4 years ago

@nelsonic Have you been able to come to any conclusions regarding the installation of the flutter on the Mac?

nelsonic commented 4 years ago

@miguelmartins17 as per my comments above, I eventually figured out how to install everything and add my Android device. Did you install flutter on the MacBook Air? And if you did where did you document all the steps involved?

miguelmartins17 commented 4 years ago

@nelsonic Since I've been working on putting the app on Google Play Store, I haven't installed Flutter on Mac yet. I started working on the TodoList on Flutter. And I've taken it all out documented when I get to some important point.

miguelmartins17 commented 4 years ago

Did anyone have problems opening Visual Studio Code ? If so, what was the solution?

image

nelsonic commented 4 years ago

@miguelmartins17 I posted the solution to that yesterday (see above) image

Open Settings > Security Then click on "Open Anyway" visual-studio-code-open-anyway

miguelmartins17 commented 4 years ago

Am I Doing Something Wrong ? Screen Shot 2020-01-11 at 16 02 23

iteles commented 4 years ago

@nelsonic I don't see a PR open for this but wanted to triple-check. Are you already putting this into a readme or shall I do it as I go?

nelsonic commented 4 years ago

@iteles I'm very happy for someone else do the documentation for a change ... 🤔 Especially someone who recently received a Mac and is learning to develop cross-platform apps ... 😉

miguelmartins17 commented 4 years ago

This should be documented the "installation of Flutter on Mac" is much more complex than windows just run Android Studio and install it from there. 😆

nelsonic commented 4 years ago

@miguelmartins17 sounds like you have a perfect opportunity to learn how to use vi / vim on mac to edit your ~/.bash_profile file 😉 https://github.com/dwyl/learn-vim

e.g:

vi ~/.bash_profile

The reason for having multiple code editors on your computer is so that you can quickly switch between them if you have multiple projects open in different programming languages. The reason for learning vi / vim is that it's the editor that comes with Linux/Unix and therefore if you are doing "server" or embedded systems work, you can always expect it to be available.

miguelmartins17 commented 4 years ago

I ran that command and it turned out this was supposed to be Flutter's path. Screen Shot 2020-01-11 at 16 26 08

miguelmartins17 commented 4 years ago

@nelsonic You're right, all the information is welcome the more you learn the better.

nelsonic commented 4 years ago

Rather than using Visual Studio Code, I'm using Android Studio (for now because it gives more info) However there isn't an easy way to open https://stackoverflow.com/questions/35363546/open-androidstudio-project-from-command-line-on-osx Thanks to @gradyplayer and @PKeno we can add a simple shortcut to open Android Studio. Edit your ~/.bash_profile file:

vi ~/.bash_profile

Once the file is open, add the following lines:

alias androidstudio="open -a /Applications/Android\ Studio.app"
alias as="open -a /Applications/Android\ Studio.app"

Save the file (press the Esc key and type :wq then hit the Enter key)

Restart your terminal/iTerm. Now when you re-open Terminal/iTerm, you can type:

androidstudio .

That "full stop" means open the current directory (whichever directory you are in) in Android Studio. Obviously I'm using the shorter version:

as .
miguelmartins17 commented 4 years ago

@nelsonic I think I've made it even with the phone connected, no more errors. Screen Shot 2020-01-12 at 12 06 20

nelsonic commented 4 years ago

Trying to install Flutter on MacBook Pro got: image

Retrying ...

nelsonic commented 4 years ago

XCode ... another 7.5Gb ... I'm _lucky enough to have decent (unlimited) bandwidth. image I fell sorry for people who are on slow/metered connections, they are basically blocked from iOS Dev. 🤦‍♂

nelsonic commented 4 years ago

Got it working on Mac: image

gradyplayer commented 4 years ago

Ha, I haven’t ever gotten a github mention for something I did on stackoverflow before, I am glad it helped