깃허브에서 내려받은 플러터 프로젝트가 실행 또는 빌드가 되지 않을 때

When the flutter project downloaded from GitHub doesn't run or build

 

[ko]

 

* 다운로드 받은 프로젝트든 다른 프로젝트든 최초에 pubspec.yaml 파일이 열린 화면의 상단에서 'Packages get' 클릭은 가장 먼저 실행해야 하는 작업입니다.

 

1. Android Studio의 플레이 버튼(빌드 버튼)이 아니라 하단 터미널에서 flutter run으로 실행하면 해결되는 경우가 있습니다.

 

2. 프로젝트  open 직 후, Dart SDK 관련 메세지가 나타는 경우

 - Android Studio의 해당 프로젝트 화면 상단에서 Dart SDK를 적용하는 것으로 선택('Enable Dart support' 를 클릭)하고, Dart SDK path를 설정합니다.

 - Dart SDK path 설정 : 좌측 상단의 Android Studio - Preferences - Languages & Frameworks - Dart - Dart SDK path 에 아래 경로를 설정합니다. 아래 경로에서 flutter 까지의 경로는 자신이 flutter sdk를 설치(저장)한 경로입니다.

 - Dart SDK path : /Users/<user_name>/development/flutter/bin/cache/dart-sdk

 

3. 빌드 진행시 권한 관련 에러메세지가 나타나는 경우

 - 에러 메세지 :

Running Gradle task 'assembleDebug'...

[!] Gradle does not have execution permission.

    You should change the ownership of the project directory to your user, or move the project to a directory with execute permissions.

 - 해결(권한 변경) : chmod a+rx android/gradlew

https://stackoverflow.com/questions/58901828/error-in-running-flutter-project-which-no-permission

 

4. 빌드 진행시 안드로이드X 관련 에러 메세지가 나타나는 경우

 - 에러 메세지 : 

[!] Your app isn't using AndroidX.
    To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY.

 - 해결(안드로이드X로 마이그레이션)

 : 프로젝트 - android - 마우스 오른쪽 버튼 클릭 - Flutter - Open Android module in Android studio --> 새 창에서 열기 선택

--> android 폴더가 열리고 완전히 동기화 될 때까지 기다림. --> Plugin update가 필요하다는 메세지가 나오면 update를 클릭

--> 업데이트가 완전히 끝나면 상단 메뉴 - Refactor - Migrate to AndroidX를 선택. --> 마이그레이션 진행. --> Do refactor 클릭

 

5. 빌드 진행시 위젯 바인딩 관련 에러 메세지가 나타나는 경우

 - 에러 메세지 :

If you're running an application and need to access the binary messenger before `runApp()` has been called (for example, during plugin initialization), then you need to explicitly call the `WidgetsFlutterBinding.ensureInitialized()` first.

 - main 함수의 runApp() 실행전에 WidgetsFlutterBinding.ensureInitialized() 를 넣어주고, 프로젝트를 재오픈해서 다시 빌드합니다.

 

*** 위의 경우 외에 flutter sdk version 자체가 안 맞는 경우는 위의 방법으로는 해결되지 않으며, 해당 프로젝트가 만들어진 또는 해당 프로젝트에 최적화된 플러터 sdk 버젼을 설치해야 합니다. (이 때 터미널 명령어로 강제로 다운그레이드하면 플러터 SDK version이 stable channel이 아닌 unknown channel에서 작동하기 때문에, dependencies 들이 제대로 설치, 삭제가 되지 않는 등의 예상치 못한 문제가 발생할 수 있으며, 이러한 경우 가장 깔끔한 해결 방법은 대상 SDK 버젼을 새로 내려받아서 임시로 Flutter SDK 버젼 설정을 바꾸는 방법이 가장 안전함.)

 

[en]

 

* Clicking 'Packages get' at the top of the screen where the pubspec.yaml file is initially opened, whether it is a downloaded project or another project, is the first thing you need to do.

 

1. Running flutter run on the bottom terminal, not the Play button (build button) in Android Studio, sometimes resolves this.

 

2. If the Dart SDK related message appears right after the project is opened  

 - Choose to apply Dart SDK(Click 'Enable Dart support')at the top of the project screen of Android Studio, and set the Dart SDK path.  - Dart SDK path setting: Set the following path in Android Studio-Preferences-Languages ​​& Frameworks-Dart-Dart SDK path at the top left. The path from the path below to flutter is where you installed (saved) the flutter sdk.  

 

 - Dart SDK path: / Users / / development / flutter / bin / cache / dart-sdk

 

3. If an error message regarding permission appears during build

 - Error message: Running Gradle task 'assembleDebug' ... [!] Gradle does not have execution permission.     You should change the ownership of the project directory to your user, or move the project to a directory with execute permissions.  

 - Resolution (Permission change): chmod a + rx android / gradlew

https://stackoverflow.com/questions/58901828/error-in-running-flutter-project-which-no-permission

 

4. Android X related error message appears during build process  

 - Error message: [!] Your app isn't using AndroidX.     To avoid potential build failures, you can quickly migrate your app by following the steps on https://goo.gl/CP92wY.  

 - Resolution (Migrate to Android X)  : Project-android-right click-Flutter-Open Android module in Android studio-> select open in new window -> Wait for android folder to open and sync completely. -> If you get a message that the plugin update is required, click update. -> After the update is complete, select the top menu-Refactor-Migrate to AndroidX. -> Progress of migration. --> click 'Do refactor'

 

5. If a widget binding related error message appears during the build process  

 - Error message: If you're running an application and need to access the binary messenger before `runApp ()` has been called (for example, during plugin initialization), then you need to explicitly call the `WidgetsFlutterBinding.ensureInitialized ()` first.   - Add WidgetsFlutterBinding.ensureInitialized () before running runApp () of the main function, reopen the project and rebuild.

 

 

*** If the flutter sdk version itself is not correct in any of the above cases, the above solution will not be solved, and you will need to install the flutter sdk version for which the project was created or optimized. (Forcibly downgrading to a terminal command at this time may cause unexpected problems, such as dependencies not being installed or removed properly, since the flutter SDK version works on an unknown channel rather than a stable channel. The safest way is to download a new SDK version and temporarily change the Flutter SDK version settings.)

 

+ Recent posts