skip to Main Content

When working on a Mac with Flutter in Android Studio (Arctic Fox 2021.3.1 Patch 4 and XCode 13.1 and/or 13.2):

If you move the root folder of your Flutter project using Finder, then open it in Android Studio and run it, the original folder location is still re-written (multiple sub folders with empty contents, usually, but not always).

Also, the moved project will no longer build from within XCode.

This means that if you don’t know the final desired location for your project at the time you create it, you will not be able to move it without weird stuff happening.

How can you move a Flutter project that was created with Android Studio without it having weird side-effects?

More info on how to reproduce:

  1. Close all IDEs

  2. Open Android Studio

  3. Using Android Studio, create a new default FLUTTER project using Java as the Android code choice

  4. Using Android Studio, run this project on an Android Emulator

  5. Using Android Studio, run this project on an IOS simulator

  6. Using Android Studio, open the project in XCode (right-click ios folder and select FlutterOpen project in Xcode)

  7. Using XCode, run the project on an IOS simulator

[everything should have worked so far]
  1. Close all IDEs

  2. Using Finder, move the project folder to a new location that is at the same depth as its current folder, but with a different parent folder. Meaning if current location is: [root]/x/y/a/my_project_original, the destination would be: [root]/x/y/b/my_project_copy

  3. delete the original folder and remember where it was

  4. Using Android Studio, open the project from its new location

  5. Using Android Studio, open the project in XCode (right-click ios folder and select FlutterOpen project in Xcode)

  6. Attempt to run on IOS simulator

[observe error – "Command PhaseScriptExecution failed with a nonzero exit code" // "file not found exception"]
  1. Using Finder, check to verify original folder location has NOT been re-written

  2. Using Android Studio, run the project on Android emulator

[observe that original folder has been re-written!]

2

Answers


  1. Here are the steps I follow to move a project’s location on my mac :

    • Close your project on Android Studio (File > Close Project)
    • Close Android Studio
    • Move your project to your new location
    • Open Android Studio
    • Delete your project from the Recent Projects (on the list of Recent Projects, click on the Settings icon on the right, and "Remove from recent projects")
    • Click on "Open" and select your project in the new location.
    • Delete the .idea file and build/ folder

    The steps should be the same within XCode (in the main window, remove the old location from your recent projects, and Open the new location)

    Login or Signup to reply.
  2. You can move your Flutter project anywhere, as long as you don’t move the files inside the project relative to each other.

    A note about pod install: If you are immediately running from Xcode, you need to run pod install inside the ios folder after adding a plugin to your pubspec.yaml. If you run flutter run or use Android Studio to run it, that will run pod install for you automatically. However, you don’t have to run pod install after moving the project, I’ve just tested it.

    If you move the root folder of your project using Finder, then open it
    in Android Studio and run it, the original folder location is still
    re-written (multiple sub folders with empty contents, usually, but not
    always).

    This only happens if you kept Android Studio open when moving the files. You shouldn’t open the old project reference in Android Studio, you should open the project using File > Open....

    Also, the moved project will no longer build from within Xcode.

    If you provide the errors, that will help us help you.

    How can you move a Flutter project that was created with Android Studio without it having weird side-effects?

    I have not found any side effects of moving a Flutter project. Quit Android Studio if it is running, and open it using File > Open.... Or if you are in terminal, run (if installed using Jetbrains toolbox) open -a ~/Applications/JetBrains Toolbox/Android Studio.app/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search