Flutter: Open android module in Android Studio is disabled

ID : 131403

viewed : 7

Tags : androidandroid-studioflutterandroid

Top 5 Answer for Flutter: Open android module in Android Studio is disabled

vote vote

96

>>> Only applies for Idea Intellij IDE

Okay, I finally figured out why the option is not available (greyed out).

It should be the inconsistency problem between the old version of the flutter plugin and a new one.

You might experience this issue if you created the project with a relatively old version flutter engine, and open it with a new version flutter plugin.

To know what happens and how to resolve it:

The old project contains a file: android.iml

which is not the same as in a latest created project: $projectname_android.iml

So you know how to fix the issue:

Rename the iml file to (YourProjectName_android.iml) That would instantly make the menu highlight again!

vote vote

87

Simply do the following:

  1. Right click on android folder > New > File
  2. Rename the new file myproject_android.iml (change myproject to your project name)
  3. Paste the bellow xml code and save it
  4. Right click on android folder > Flutter > Open Android Module in Android Studio
  5. Voila

Xml code:

<?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$">       <sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />       <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />       <excludeFolder url="file://$MODULE_DIR$/.dart_tool" />       <excludeFolder url="file://$MODULE_DIR$/.idea" />       <excludeFolder url="file://$MODULE_DIR$/.pub" />       <excludeFolder url="file://$MODULE_DIR$/build" />     </content>     <orderEntry type="sourceFolder" forTests="false" />     <orderEntry type="library" name="Dart SDK" level="project" />     <orderEntry type="library" name="Flutter Plugins" level="project" />     <orderEntry type="library" name="Dart Packages" level="project" />   </component> </module> 
vote vote

74

Because you lost the xxx_android.iml file in android directory, it cannot be recognized as an android project.

So you only need to copy a xxx_android.iml file from other projects to the android directory.

Note, replace xxx with your project name

vote vote

65

Go to

tools -> flutter -> open in exisiting android studio. 

If it is not showing, then create a Dummy project in flutter, after that dummyFil.iml is generating with new Flutter Plugins.

Paste the dummyFil.iml file in your project.

You will see a option as open in existing android studio option.

vote vote

55

The easiest way is to use this command in the root directory of your project, it will create some missing files and it will definitely work.

flutter create --platforms=android . 

Now just right click to Android folder

enter image description here

Top 3 video Explaining Flutter: Open android module in Android Studio is disabled

Related QUESTION?