Flutter project opening in Android Studio with just the Android module

Viewed 3044

My project structure only consists of the Android module, and doesn't show the ios and lib directory. Besides, why is the Android directory treated as a module rather than just a directory? It also has its own iml file named project_name_android.iml. I'm not able to run the project because AS complains that the entry point (main.dart) is missing. When I check in the folder, it's actually there, but it won't show on AS.

Here's a screenshot: enter image description here

3 Answers

I solved this problem on Android Studio OSX, this is my steps :

  • Android studio -> File -> Project Structure
  • On project setting dialog -> see menu -> choose Module
  • Choose your project -> click <+ Add content root>
  • Choose your root flutter project folder -> OK to finish
  • everything comes back to you

Hope this help

I would suggest to check if you have the file yourProjectName.iml in the root folder of project. If that file does not exist then Android Studio doesn't know which folder structure to create and for this you cannot see you lib folder when it displays the window to set the flutter entry point.

Further to https://stackoverflow.com/users/5643951/taulant-loshi answer above, please add yourProjectName.iml file in the root folder of project with the following contents:

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <excludeFolder url="file://$MODULE_DIR$/.pub" />
      <excludeFolder url="file://$MODULE_DIR$/build" />
      <excludeFolder url="file://$MODULE_DIR$/.dart_tool" />
    </content>
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Dart SDK" level="project" />
    <orderEntry type="library" name="Dart Packages" level="project" />
    <orderEntry type="library" name="Flutter Plugins" level="project" />
  </component>
</module>
Related