How to import existing Flutter Project in Android Studio?

ForumCategory: QuestionsHow to import existing Flutter Project in Android Studio?
shubhamhackz asked 2 years ago

I have facing some error while opening the projects downloaded from here.

jeffzane replied 2 years ago

I have successfully imported the project in two ways. You can refer to my answer. https://stackoverflow.com/a/49974562/8163851

4 Answers
boeledi answered 2 years ago

I faced the same problem and so far, the only solution that worked for me was to use Visual Studio Code and open the folder that contains the project.
After resolving any potential dependencies, I was able to run the project.

brwskitime replied 2 years ago

That didn’t work for me. I have the Flutter plugin installed. I can create a new Flutter project. If I delete the project from the welcome screen project list, then try to import it fresh from file, Android Studio doesn’t know how to open it.

admin Staff replied 2 years ago

Did you try this?

Enable flutter plugin in Android Studio then it’s possible.

To install it:

Start Android Studio.
Open plugin preferences (Preferences>Plugins on macOS, File>Settings>Plugins on Windows & Linux).
Select Browse repositories…, select the Flutter plug-in and click install.
Click Yes when prompted to install the Dart plugin.
Click Restart when prompted.

https://flutter.io/get-started/editor/

brwskitime answered 2 years ago

Did anyone figure this out?

Remy_G answered 2 years ago

Try to create a new flutter project to a new location, close the project, then just copy/paste the existing project source files (except .gitignore)  into the new location (replace all).

Open the project again, go to the pubspec.yaml to do a packages get / Packages upgrade, then it should work :)

(Tested on Android Studio for Mac OS )

Remy_G replied 2 years ago

Otherwise, check if there is a local.properties file in your existing project (project/android/local.properties).
In my case it was missing, and after adding it manually , I could use the “Open existing Android Studio Project” correctly =)

local.properties file should contain something like this :
sdk.dir= [Android SDK Path]
flutter.sdk= [Flutter Path]
flutter.buildMode=debug

Remy_G replied 2 years ago

Otherwise, check if there is a local.properties file in your existing project (project/android/local.properties).
In my case it was missing, and after adding it manually , I could use the “Open existing Android Studio Project” correctly =)

local.properties file should contain something like this :
sdk.dir= [Android SDK Path]
flutter.sdk= [Flutter Path]
flutter.buildMode=debug

patel.krunal answered 1 month ago

Solved Here