Could not create task ... this and base files have different roots

2,175

Solution 1

I fixed mine by moving the project directory to the same drive. My project was stored in E:\ so, I moved it to C:.

My answer is almost the same as rvr93's answer but I did not add anything to the environment variables.

Solution 2

I had your same issue, Gradle couldn't sync the android module, I solved it by deleting the android/ directory from the Flutter project, then recreate it using the command flutter create --platforms android .

Notice the "." at the end of the command it's part of it, it means create the Android project in the current directory.

Share:
2,175
knobi
Author by

knobi

Starting flutter developing android&ios Apps, so very new to all this. :)

Updated on January 01, 2023

Comments

  • knobi
    knobi over 1 year

    I've built an app with Android Studio and Flutter and wanted to generate a signed APK. When I go to Tools->Flutter->Open Android module in Android Studio, it starts to build the project.

    But after some time I get this Error and I don't know how to change the roots or what to do. It seems like the problem are just two packages (url_launcher and shared preferences)

    My Project is on my hard disk F: and the flutter folder is on my hard disk C:

    Error Message "Could not create task..."

    Is this maybe because my project is on F: and the flutter folder with the packages in C: ? How can I change the flutter folder to F: ?

    • Ali FELLAHI
      Ali FELLAHI over 2 years
      I'm also having this issue, did you managed to solve it?
  • knobi
    knobi over 2 years
    Thanks that's good to know :) I just had a work around and copied the whole project to the C: hard disk. Then it worked :)