How to open an existing Flutter Project in Android Studio

前提是你 提交于 2020-08-24 05:33:13

问题


I might sound noob here but I can't see a clear way of opening existing Flutter Project in Android Studio 3.1.2.

I checked this but it didn't work. So I want to know if there is a standard IDE way of doing this? I also can't find any docs clearly mentioning it. Do I need to install a 3rd party plugin?

After opening it as an Existing Android Studio Project, I get the following error:

The error is solved by running Get Dependencies. Is it a normal behavior?


回答1:


  1. Install Flutter plugin for Android studio: https://flutter.io/get-started/editor/

  2. Open Android Studio

  3. Open existing Android Studio project by using one of below methods:


EASIEST WAY: Drag your project folder and drop to Android Studio.


Other ways:




回答2:


Looks like Android Studio can't load Android Application module from Flutter project automatically. I also have same problem, so in my situation Gradle can't be found, because of lack of Android project.

There's important note from official site:

Important: Do not use the New > Project from existing sources option for Flutter projects

I suggest, same is for Open option.




回答3:


The quickest way on macOS is open -a Android\ Studio android when you are in the root project directory.


Alternatively, if you use the jetbrains toolbox, you can enable "Shell Scripts" in its settings. This will create a binary in the folder of your choice, so you have to add this folder to your PATH. Then, you can use studio . inside the Android folder, or studio android in the flutter project. The benefit of this, is it also works with other Jetbrains products (e.g. charm project_dir or clion project_dir. Unfortunately this method glitches out (for pycharm at least).




回答4:


I know it's already late, but you can open an existing Flutter project in Android Studio by following these steps (make sure you have already installed Flutter & Dart plugin and Flutter SDK):

  1. Click Open from File menu in Android Studio,
  2. Go to the path of the project,
  3. Click Open from the dialog,
  4. When the project opens in Android studio, it will show an error of packages and dependencies. So, click on Get Dependencies on the top. Android Studio will automatically add all the required dependencies and packages.



回答5:


What works for me was to open existing Android Studio project like mentioned above, and then go to menu

Tools -> Flutter -> Flutter Clean

Then configuration window will open and ask you to locate flutter sdk. After locating the sdk, click OK and then the flutter functions will be available (Pub buttons, runs menu)



来源:https://stackoverflow.com/questions/50548629/how-to-open-an-existing-flutter-project-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!