flutter doctor 실행시 각종 에러 해결

oen·2023년 2월 19일
5

🇫 Flutter

목록 보기
14/14

플러터 설치 후 에러들

yeinlee@yeinleeui-MacBookPro ~ % flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.
[✓] Flutter (Channel stable, 3.7.1, on macOS 13.2 22D49 darwin-x64, locale ko-KR)
[✗] Android toolchain - develop for Android devices
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
[✗] 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 see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
[!] Android Studio (version 2022.1)
    ✗ Unable to find bundled Java version.
[✓] VS Code (version 1.75.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability

! Doctor found issues in 3 categories.

하나하나씩 해결해 보자!


1. The operation couldn’t be completed. Unable to locate a Java Runtime. Please visit http://www.java.com for information on installing Java

자바가 없으니까 링크로 들어가서 설치하라고 한다.
하지만 난 brew로 설치하겠어!

brew tap AdoptOpenJDk/openjdk
brew install --cask adoptopenjdk

jdk 설치

yeinlee@yeinleeui-MacBookPro ~ % java --version
openjdk 16.0.1 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-16.0.1+9 (build 16.0.1+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-16.0.1+9 (build 16.0.1+9, mixed mode, sharing)

java -version 으로 설치 확인완료

여기까지 하고 다시 flutter doctor 입력하면 자바 설치 오류는 사라져있다 ~!!

2. Android toolchain

2-1. cmdline-tools component is missing


Android SDK Command-line Tools (latest) 패키지가 설치 되어있지 않았다. 체크하고 Apply를 눌러서 설치한다.

2-2. Android license status unknown.

안드로이드 SDK 사용 동의가 제대로 되지 않은 경우 이 에러가 표시된다.

flutter doctor --android-licenses 명령 실행
-> java.lang.UnsupportedClassVersionError 에러 발생
높은 버전의 JDK에서 컴파일한 class 파일을 낮은 버전의 JDK에서 실행을 해서 발생하는 에러이다.

실행환경과 컴파일할 자바버전을 맞춰줘야 한다.

-> brew install openjdk

-> brew link --force openjdk@19

->

yeinlee@yeinleeui-MacBookPro ~ % java --version
openjdk 19.0.2 2023-01-17
OpenJDK Runtime Environment Homebrew (build 19.0.2)
OpenJDK 64-Bit Server VM Homebrew (build 19.0.2, mixed mode, sharing)

-> vi ~/.zshrc 로 파일을 열고
->

export JAVA_HOME="/usr/local/opt/openjdk"

저장

-> source ~/.zshrc 로 파일 재실행
-> flutter doctor --android-licenses 가 문제없이 실행된다 ! (엉엉 여기까지 조금 헤맸다...)

3. Xcode - develop for iOS and macOS

3-1. Xcode installation is incomplete; a full installation is necessary for iOS development.

나는 Xcode를 앱스토어에서 이미 설치했었어서, 메세지에 나오는대로

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
sudo xcodebuild -runFirstLaunch

명령어를 실행하니 해당 오류가 해결되었다 :)

3-2. CocoaPods not installed.

메시지에 나온대로 https://guides.cocoapods.org/using/getting-started.html#installation for instructions. 에 들어가보니까

이렇게 설치하라고 나와있다.

sudo gem install cocoapods 명령어 실행하는걸로 코코팟 설치 완료!

4. Android Studio (version 2022.1)

4-1. Unable to find bundled Java version.

안드로이드 스튜디오가 Java JDK 경로를 인식하지 못하는 오류이다.

Finder에서 응용 프로그램 열고 Android Studio 오른쪽 클릭
-> 패키지 내용 보기 클릭

-> Contents 폴더를 열면 jbr폴더가 있는데, 같은 경로에 복사한 후 이름을 jre로 변경한다.
끝!


완료!


모두 해결 완료!
초록빛이 영롱하다 영롱해 ... ><

profile
🐾

2개의 댓글

comment-user-thumbnail
2023년 2월 23일

설치하는데 도움이 많이 되었습니다. 정리 정말 잘하셨는데요!

1개의 답글