Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(When) should I expect the "Open for Editing in Android Studio" option to show in Android Studio? #6416

Closed
msbit opened this issue Dec 4, 2022 · 5 comments
Labels
waiting for customer response Auto-close if no response

Comments

@msbit
Copy link

msbit commented Dec 4, 2022

Steps to Reproduce

Going through https://codelabs.developers.google.com/codelabs/admob-inline-ads-in-flutter, at step 8, I am instructed to:

Open the android/build.gradle file (or any file under the android folder), and click Open for Editing in Android Studio to open an Android project.

This option isn't showing up, so I'm wondering:

  • should I expect to see the option when using Android Studio itself?
  • if so, and this scenario doesn't trigger that option, what scenario should?

The tutorial doesn't specifically note that it's using Android Studio, but the screenshots up to that point appear to be AS, and the Pub get command appears as expected from the Flutter plugin, so I'd suggest that's what the author intended.

Version info

/Users/tom/opt/flutter/flutter_macos_3.3.4-stable/bin/flutter doctor --verbose
[✓] Flutter (Channel stable, 3.3.4, on macOS 11.7.1 20G918 darwin-x64, locale en-AU)
    • Flutter version 3.3.4 on channel stable at /Users/tom/opt/flutter/flutter_macos_3.3.4-stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision eb6d86ee27 (9 weeks ago), 2022-10-04 22:31:45 -0700
    • Engine revision c08d7d5efc
    • Dart version 2.18.2
    • DevTools version 2.15.0

[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/tom/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode-13.2.1.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] IntelliJ IDEA Community Edition (version 2022.2.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.73.1)
    • VS Code at /Users/tom/Downloads/VSCode-darwin/Visual Studio Code.app/Contents
    • Flutter extension version 3.52.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 11.7.1 20G918 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 107.0.5304.121

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
Process finished with exit code 0
@stevemessick
Copy link
Member

My guess is that project is based on an old Flutter template. It looks like it is missing the Android module. If I'm right then you can fix it using the Project Structure dialog.

Use File > Project Structure to open it. In the left pane, select Modules. In the middle pane, select the name of your project. If my guess is correct, it will not have any dependents. (If it has an arrow to show children then my guess is probably wrong.) You can add an Android module by using the + in the middle pane. That will display the Add menu. It might have an option for Android but if it doesn't then select New Module and choose Android from the list.

Let us know if that helps.

@stevemessick stevemessick added the waiting for customer response Auto-close if no response label Dec 5, 2022
@msbit
Copy link
Author

msbit commented Dec 6, 2022

Hey @stevemessick it looks like you're correct, there's just the one entry at the top level, the starter module.

I've tried 3 options from that project structure screen:

  • add an Android framework, which added a node beneath the starter module and an Android entry on the project navigator drop-down near the top left, but this is always empty
  • add a New Module which appears to be creating an entirely new Android application beneath starter so doesn't seem to fit the bill
  • Import Module, pointing it at the android/app directory which also adds the Android entry on the project navigator drop-down, but it appears to only be partially populated (some java files, no *.gradle files)

Is there some documentation around that covers the nuances of adding/importing/configuring modules to existing Flutter projects like this?

@github-actions github-actions bot removed the waiting for customer response Auto-close if no response label Dec 6, 2022
@stevemessick
Copy link
Member

This comment has a screen shot showing what to do. I believe it corresponds to your second option. It is creating an Android module that is a dependent of your project. Android Studio became very picky about when their menu items and tool windows would be active, so now we have to have an Android module in every Flutter project that targets Android. Projects created using Flutter tools automatically create one.

@stevemessick
Copy link
Member

I created an issue to (hopefully) fix the root cause of this problem.
googleads/admob-inline-ads-in-flutter#43

@msbit are you able to open the file in Android Studio now?

@github-actions
Copy link

Without additional information we're not able to resolve this issue, so it will be closed at this time. You're still free to add more info and respond to any questions above, though. We'll reopen the case if you do. Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for customer response Auto-close if no response
Projects
None yet
Development

No branches or pull requests

2 participants