简体   繁体   English

作为 Flutter 项目运行 Android (Java) 项目的 Android Studio

[英]Android Studio running Android (Java) Project as Flutter Project

Situation and Problem情况与问题

I have been working with Android Projects using android studio for a while in Java.我在 Java 中使用 android studio 处理 Android 项目已经有一段时间了。 Recently, I have started learning Flutter and therefore added Flutter modules into Android Studio.最近,我开始学习 Flutter,因此在 Android Studio 中添加了 Flutter 模块。

I opened both Android Project and Flutter Project at the same time in different windows and both project can share the same emulator, and everything seemed to work fine.我在不同的窗口中同时打开了 Android 项目和 Flutter 项目,两个项目可以共享同一个模拟器,一切似乎都很好。 Yet, the next day I opened the Android Project again, the WHOLE IDE was configured with Flutter settings.然而,第二天我再次打开 Android 项目,整个 IDE 配置了 Flutter 设置。 This means that:这意味着:
1. Android Project is NOT synced with gradle, and thus all the imports failed marked red 1. Android 项目未与 gradle 同步,因此所有导入失败标记为红色
2. All gradle related files are not visible in the project folder in Android Studio (still exists in folder) 2.在Android Studio中的项目文件夹中看不到所有gradle相关文件(文件夹中仍然存在)
3. All gradle operations are gone because the IDE is configured for Flutter. 3.所有gradle操作都没有了,因为IDE是为Flutter配置的。 So there is no rebuild project/clean project/ sync with gradle files button所以没有重建项目/清理项目/与 gradle 文件同步按钮

Things I have tried我尝试过的事情

  1. Reopen the project重新打开项目
  2. Invalidate cache and restart使缓存无效并重新启动
  3. Restart PC重启电脑

But none of them seemed to work.但它们似乎都不起作用。 If I tried to create a new Android Project, the new Android Project seems to work fine with all gradle operations available.如果我尝试创建一个新的 Android 项目,新的 Android 项目似乎可以在所有可用的 gradle 操作下正常工作。

Android Studio Versions Android Studio 版本

Android Studio 3.4 JRE: 1.8.0_152-release-1343-b01 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains sro Windows 10 10.0 Android Studio 3.4 JRE: 1.8.0_152-release-1343-b01 amd64 JVM: OpenJDK 64-Bit Server VM by JetBrains sro Windows 10 10.0

I tried to look for similar issues but none seems to match this one.我试图寻找类似的问题,但似乎没有一个与这个问题相匹配。 Any one can help?任何人都可以帮忙吗?

I had a similar issue.我有一个类似的问题。 Yesterday, I updated Android Studio to 3.6.1 and that fixed it.昨天,我将 Android Studio 更新到 3.6.1 并修复了它。 Try that.试试那个。

I found the workaround solution is to import the project again instead of opening the project.我发现解决方法是再次导入项目而不是打开项目。

When importing, remember to choose opening it as an Android Gradle Project.导入时记得选择将其作为 Android Gradle 项目打开。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM