Can't find Open for Editing in Android Studio

Viewed 11476

I'm new to flutter. I want to open (android)module of flutter to another window. But there's no option visible in java file or any other android file. check this image

here is my flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale en-IN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[!] iOS tools - develop for iOS devices
 ✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:
    brew update
    brew install --HEAD usbmuxd
    brew link usbmuxd
    brew install --HEAD libimobiledevice
    brew install ideviceinstaller
[✓] Android Studio (version 3.1)
[!] VS Code (version 1.42.1)
✗ Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (1 available)
! Doctor found issues in 2 categories.
7 Answers

The problem is caused by missing .iml project files. These files are added automatically to the .gitignore file but they should not. To fix it:

  1. Delete .idea folder.
  2. Create a new temporary Flutter project with the same name.
  3. Copy from the project to your existing project these 2 missing files:
  • [project_name].iml
  • android/[project_name]_android.iml
  1. Open Android Studio and the problem should be gone.

To avoid it in the future, make sure .iml files are not excluded in the gitignore. There is a Github issue on this topic.

Easiest tip that worked for me: Create new file under android, give it the following name:

[project_name]_android.iml

Leave it empty then re-try the option. Works like charm!

create a file in android studio inside android name

[project_name]_android.iml

enter image description here

copy paste bellow 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$" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="Dart SDK" level="project" />
  </component>
</module>

another solution: you can copy this file from another app and rename as like [project_name]_android.iml then paste in your project

Got to your project view on the left, then find the folder labeled "android" (it will have your current project name next to it in brackets). Right click, then navigate to Flutter > Open Android module in Android Studio.

Alternatively, if you open any file (e.g. build.gradle) in that "android" subdirectory, you will see Open for Editing in Android Studio at the top right. If you happened to click "hide" on this banner previously, simply restart the IDE. Source.

What happens when you right click on the Android folder -> flutter? Can you open the Android project from there?

This option has stopped working for me after I allowed Android Studio to generate Android project from the "Android project detected" popup suggestion.

I afraid it messed up something in Android Studio settings. I was able to fix it only after deleting all its settings. I guess there should be a more elegant solution.

You can always do it the simple way, File -> Open -> inside the project's folder, select android, and open it in a different window

If you're not seeing that option, you can try this:

  1. Press cmd + shift + o and search for build.gradle file:

    enter image description here

  2. Once you open it, you'll see Open for Editing in Android Studio option at top right corner.

    enter image description here

Related