Flutter not found when developing plugin for Android

4,136

Solution 1

It worked for me when I did the next steps (assuming that Dart and Flutter plugins are configured in the Android Studio Preferences properly):

  1. Close all the projects up until you see the "welcome to Android Studio" window with recent projects list and a set of options in the center
  2. Select "Open existing Android Studio project"
  3. Select the file plugin/example/android/build.gradle

Solution 2

You should open the project in android studio from the example/android location.

Solution 3

It turned out to be a known error: https://github.com/flutter/flutter/issues/19830. You can find different solutions and general discussion of the problem there.

Provided solutions did not help in my case. What had worked out is this one (by @incloudss):

For everyone who still struggles with that problem, ignore the official documentation, and do not open android project the way they describe it there.

Instead:

  1. Open the main flutter project.
  2. Go to Tools -> Flutter -> Open For Editing In Android Studio(yes, it doesn't >make sense because we are already in AS, but it works).

Solution 4

You need to install the Flutter SDK https://flutter.dev/docs/get-started/install/windows#get-the-flutter-sdk

Then in Android Studio, go to settings>plugins, and install the Flutter and Dart plugins.

Then check whether you have provided you SDK path at Settings> Language & Frameworks > Flutter

Share:
4,136
Leonardo da Silva
Author by

Leonardo da Silva

Developing an online multiplayer game in Flutter called Fibula Wars.

Updated on December 21, 2022

Comments

  • Leonardo da Silva
    Leonardo da Silva over 1 year

    I forked a plugin with the intent to make an update to use the embedding v2 for Android. But when I opened the android folder on Android Studio it does not find Flutter. It fails to import these classes:

    import io.flutter.plugin.common.MethodChannel;
    import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
    import io.flutter.plugin.common.MethodChannel.Result;
    import io.flutter.plugin.common.MethodCall;
    import io.flutter.plugin.common.PluginRegistry.Registrar;
    

    Is there anything I am missing to edit the Android part of a Flutter plugin?

    This is the plugin I am trying to update: https://github.com/lslv1243/launch_review

    Thanks in advance!

  • Leonardo da Silva
    Leonardo da Silva almost 4 years
    I do have these installed
  • Leonardo da Silva
    Leonardo da Silva almost 4 years
    I am using mac and it is called "Preferences" instead of "Settings". But when I go to "Languages & Frameworks" I don't have an option called "Flutter". I do have installed both Flutter and Dart plugins in my Android Studio. Do you know what could be missing?
  • Leonardo da Silva
    Leonardo da Silva almost 4 years
    Your response is correct. My Dart version was incompatible with the Android Studio version. I updated it and it is working now. I will just check if the error goes away.
  • Leonardo da Silva
    Leonardo da Silva almost 4 years
  • Tadeo Hepperle
    Tadeo Hepperle over 2 years
    Thanks a lot, that worked for me!
  • Alexandra Damaschin
    Alexandra Damaschin over 2 years
    But why it's working to open it from plugin/example/android/build.gradle and not working from plugin/android/build.gradle ?