为 Android 开发插件时找不到 Flutter
Flutter not found when developing plugin for Android
我分叉了一个插件,目的是进行更新以使用 Android 的嵌入 v2。但是当我在 Android Studio 上打开 android 文件夹时,它没有找到 Flutter。它无法导入这些 类:
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;
我在编辑 Flutter 插件的 Android 部分时是否遗漏了什么?
这是我要更新的插件:https://github.com/lslv1243/launch_review
提前致谢!
您需要安装Flutter SDKhttps://flutter.dev/docs/get-started/install/windows#get-the-flutter-sdk
然后在 Android Studio 中,转到设置>插件,然后安装 Flutter 和 Dart 插件。
然后在设置 > 语言和框架 > Flutter 中检查你是否提供了 SDK 路径
您应该从 example/android 位置在 android 工作室中打开项目。
当我执行后续步骤时它对我有用(假设 Dart 和 Flutter 插件已在 Android Studio 首选项中正确配置):
- 关闭所有项目,直到您看到“欢迎来到 Android Studio”window,中间有最近的项目列表和一组选项
- Select“打开现有的 Android Studio 项目”
- Select 文件
plugin/example/android/build.gradle
原来是一个已知错误:https://github.com/flutter/flutter/issues/19830。您可以在那里找到不同的解决方案和问题的一般性讨论。
提供的解决方案对我的情况没有帮助。得出的结果是这个(作者 @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:
- Open the main flutter project.
- 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).
我分叉了一个插件,目的是进行更新以使用 Android 的嵌入 v2。但是当我在 Android Studio 上打开 android 文件夹时,它没有找到 Flutter。它无法导入这些 类:
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;
我在编辑 Flutter 插件的 Android 部分时是否遗漏了什么?
这是我要更新的插件:https://github.com/lslv1243/launch_review
提前致谢!
您需要安装Flutter SDKhttps://flutter.dev/docs/get-started/install/windows#get-the-flutter-sdk
然后在 Android Studio 中,转到设置>插件,然后安装 Flutter 和 Dart 插件。
然后在设置 > 语言和框架 > Flutter 中检查你是否提供了 SDK 路径
您应该从 example/android 位置在 android 工作室中打开项目。
当我执行后续步骤时它对我有用(假设 Dart 和 Flutter 插件已在 Android Studio 首选项中正确配置):
- 关闭所有项目,直到您看到“欢迎来到 Android Studio”window,中间有最近的项目列表和一组选项
- Select“打开现有的 Android Studio 项目”
- Select 文件
plugin/example/android/build.gradle
原来是一个已知错误:https://github.com/flutter/flutter/issues/19830。您可以在那里找到不同的解决方案和问题的一般性讨论。
提供的解决方案对我的情况没有帮助。得出的结果是这个(作者 @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:
- Open the main flutter project.
- 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).