flutter-intellij icon indicating copy to clipboard operation
flutter-intellij copied to clipboard

Deeper IDE integration between Android Studio and the Flutter plugin

Open workerbee22 opened this issue 4 years ago • 3 comments

Android Studio shows errors in AndroidManifest.xml. These errors are not material and do not cause a problem building the Android app version of the Flutter project. But 'Problems' are shown on the Project.

I think this has been a problem with Flutter projects in Android Studio since BEFORE Flutter v1. Untidy errors like this create confusion and undermine confidence in Flutter. Given we are at Flutter v2.5.x and we want to improve Flutter maturity, we should seek to remove such 'bogus' errors reported in the Google supported IDE.

This may be an Android tool chain issue when part of a Flutter application, but I would have thought we could have resolved these by now. Its not a good look for Devs new to Flutter.

Steps to reproduce

Android Studio / File / New / New Flutter Project Open AndroidManifest.xml located in /android/app/src/main These errors shown:

image

image

Previous Issues Logged but Closed This issue or very very similar ones keep getting raised and closed. Note that every single Flutter ap I have ever created still has these errors. There are more but here is a sample of previous issues from the Flutter repo:

June 19th 2021: #84866 May 10th 2017: #9944 March 2018: #15722

Flutter Doctor:

[✓] Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-x64, locale en-AU) • Flutter version 2.5.2 at /Users/gamma/Documents/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 3595343 (11 days ago), 2021-09-30 12:58:18 -0700 • Engine revision 6ac856380f • Dart version 2.14.3

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/gamma/Library/Android/sdk • Platform android-S, build-tools 30.0.2 • ANDROID_HOME = /Users/gamma/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.5.1, Build version 12E507 • CocoaPods version 1.11.2

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

[✓] Android Studio (version 2020.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.10+0-b96-7281165)

[✓] VS Code (version 1.61.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.27.0

[✓] Connected device (2 available) • macOS (desktop) • macos • darwin-x64 • macOS 11.6 20G165 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.81 ! Error: Mike's iPhone is not connected. Xcode will continue when Mike's iPhone is connected. (code -13)

• No issues found!

workerbee22 avatar Oct 12 '21 04:10 workerbee22

Android Studio is designed to edit Android apps, not Flutter apps. Flutter uses some of the Android framework, but is structured significantly differently than Android. When a Flutter app is open in Android studio the IDE does not recognize it as an Android app, and lots of errors are generated.

The Flutter plugin for Android Studio provides support for working with Flutter apps, but does not fully support Android. Our recommended approach for working on Android-specific portions of a Flutter app is to open the android module as a top-level project in Android Studio.

Alternatively (when it works) you can enable an experimental option in the Flutter app that will cause the android app to be indexed, providing better support for working wth the Android module directly in the Flutter app. Check the box: Preferences > Languages & Frameworks > Flutter > Enable code completion, navigation, etc. for Java / Kotlin. There are two reasons this is not enabled by default: first, it requires Gradle sync a lot more, and second, it uses unsupported APIs that frequently get broken by IntelliJ updates (not Android Studio).

TBH, repeatedly filing issues here, or Flutter, or Android, won't resolve the fundamental problem (everything works out-of-the-box). It is going to take some high-level coordination between Flutter and Android, which isn't on anyone's road map yet. @csells @adarshf @jacob314 for visibility of such.

stevemessick avatar Oct 12 '21 14:10 stevemessick

Thanks for the update @stevemessick on the wider issues with Android Studio / Flutter integration. This provides more context and explains why this issue has been present so long.

One thing I might call out is that I'm very sure this information is not widely known within the Flutter community. So one thing that occurs straight away, is that perhaps we look to get this or similar onto the flutter.dev website? Probably somewhere like this page and specifically this section, which talks about the Flutter plugin and AS experience:

https://flutter.dev/docs/development/tools/android-studio#android-ide

So you'll note that this content implies a whole bunch of things, but is not the thorough background and context you've supplied here @stevemessick . So I suspect without this extra information, Flutter devs will continue to ask questions around this and will continue to log issues here or in the Flutter repo.

Next thought @csells @adarshf @jacob314 and @domesticmouse ... how do we get the high-level coordination between Flutter and Android teams to achieve 'everything works out-of-the-box'? Given that our common goal here is an improved Flutter Developer experience?

workerbee22 avatar Oct 12 '21 21:10 workerbee22

I do like the idea of taking out false negative issues if we can, but I wouldn't prioritize this work above wringing true negative issues out of our tooling.

csells avatar Oct 12 '21 22:10 csells