Reputation: 12602
I am trying to open my flutter project separately in android studio with "Open android module in Android Studio" but when I left click on my flutter project window to open it this is disabled for me while "Open iOS module in Xcode" is there. Please let me know I can I enable it and can open my flutter project for android in another module.
Upvotes: 56
Views: 33064
Reputation: 89
Here I got this issue i make a file in project-> android-> projectname_android.iml
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android" name="Android">
<configuration>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" />
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/app/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/app/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/app/src/main/assets" />
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/app/src/main/libs" />
<option name="PROGUARD_LOGS_FOLDER_RELATIVE_PATH" value="/app/src/main/proguard_logs" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/app/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/app/src/main/kotlin" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" generated="true" />
</content>
<orderEntry type="jdk" jdkName="11" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Flutter for Android" level="project" />
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
</component>
enter code here
Upvotes: 0
Reputation: 18454
My plugin is a pure package having no example app that also caused the same issue. I fixed at following:
Generate new plugin
flutter create --template=plugin --platforms=android -a java YourPluginName
Copy example app into my plugin
Go to example/android, right click on your_plugin_example.iml, Flutter/Open for Editing on Android Studio
The flutter module is loaded so there will be no error.
Upvotes: 0
Reputation: 1035
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
Upvotes: 15
Reputation: 2990
Simply do the following:
android
folder > New
> File
android
folder > Flutter
> Open Android Module in Android Studio
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>
Upvotes: 57
Reputation: 326
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
Upvotes: 22
Reputation: 71
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.
Upvotes: 6
Reputation: 2120
>>> 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:
which is not the same as in a latest created project:
So you know how to fix the issue:
Rename the iml file to (YourProjectName_android.iml) That would instantly make the menu highlight again!
Upvotes: 57