我是颤振新手。我想将 flutter 的(android)模块打开到另一个窗口。但在 java 文件或任何其他 android 文件中没有可见的选项。
这是我的扑动医生:
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.
该问题是由于缺少
.iml
项目文件引起的。这些文件会自动添加到 .gitignore
文件中,但它们不应该添加。要修复它:
.idea
文件夹。[project_name].iml
android/[project_name]_android.iml
为避免将来出现这种情况,请确保 .iml 文件未排除在 gitignore 中。关于此主题有一个 Github 问题。
对我有用的最简单的技巧: 在android下创建新文件,命名如下:
[project_name]_android.iml
将其留空,然后重试该选项。效果就像魅力!
在 android studio 中创建一个文件 android name
[项目名称]_android.iml
复制粘贴以下代码
<?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>
另一个解决方案: 您可以从另一个应用程序复制此文件并重命名为 [project_name]_android.iml,然后粘贴到您的项目中
进入左侧的项目视图,然后找到标有“android”的文件夹(它旁边的括号中包含您当前的项目名称)。右键单击,然后导航至
Flutter > Open Android module in Android Studio
。
或者,如果您在“android”子目录中打开任何文件(例如
build.gradle
),您将在右上角看到 Open for Editing in Android Studio
。如果您之前碰巧单击了该横幅上的“隐藏”,只需重新启动 IDE 即可。 来源.
右键点击Android文件夹->flutter会发生什么?你能从那里打开Android项目吗?
在我允许 Android Studio 从“检测到 Android 项目”弹出建议生成 Android 项目后,此选项对我不再起作用。
我担心它弄乱了 Android Studio 设置中的某些内容。我只有在删除所有设置后才能修复它。 我想应该有一个更优雅的解决方案。
你总是可以用简单的方式做到这一点, 文件 -> 打开 -> 在项目文件夹中,选择 android,然后在不同的窗口中打开它
转到文件 -> 打开 然后选择 flutter 项目中的 “android” 文件夹,它会像 android 模块一样加载,并且像魅力一样工作。