简体   繁体   English

Android Studio 中的 Flutter:Build Bundle/APK 变灰

[英]Flutter in Android Studio: Build Bundle/APK greyed out

I installed Flutter and Android Studio following this link here: https://flutter.dev/docs/get-started/editor我按照这里的链接安装了 Flutter 和 Android Studio: https : //flutter.dev/docs/get-started/editor

I've been coding in flutter for two months now and can run my app in simulator or on a connected device no problem.我已经在颤振中编码了两个月,可以在模拟器或连接的设备上运行我的应用程序,没问题。

But when I try to actually build an apk via "Build" --> "Build Bundle(s) / APK", this option is greyed out.但是当我尝试通过“Build”-->“Build Bundle(s) / APK”实际构建一个apk时,这个选项是灰色的。

Android Studio: 3.3.2安卓工作室:3.3.2

You can't build apk using Build option in Android Studio if you are running your Flutter project.如果您正在运行 Flutter 项目,则无法使用 Android Studio 中的Build选项构建 apk。

There are 2 solutions to build it.有两种解决方案来构建它。

  1. In terminal, write flutter build apk (this will build apk for release version not the debug version)在终端中,编写flutter build apk (这将为发布版本而不是调试版本构建 apk)

  2. Open your module in Android Studio and you can use Build option of the Android studio to build the debug apk.在 Android Studio 中打开您的模块,您可以使用 Android Studio 的Build选项来构建调试 apk。

For option 2, you can go to build.gradle file and you should see an option in Android Studio asking you to open the module separately (see the screenshot) Tap on this option and you can then build your apk in both debug and release mode.对于选项 2,您可以转到build.gradle文件,您应该会在 Android Studio 中看到一个选项,要求您单独打开模块(请参阅屏幕截图)点击此选项,然后您可以在调试和发布模式下构建您的 apk .

在此处输入图片说明

I realize this might have already been answered, but I have another solution to this issue.我意识到这可能已经得到了回答,但我对此问题有另一种解决方案。 I was having the same problem after modifying my pubspec.yaml file, so after trying to build within terminal nothing would happen.修改我的 pubspec.yaml 文件后,我遇到了同样的问题,因此在尝试在终端内构建后,什么也不会发生。 Apparently, you have to open the .yaml file within Android Studio from your project directory in order to for AS to realize that there's been a change to the file.显然,您必须从项目目录中打开 Android Studio 中的 .yaml 文件,以便 AS 意识到该文件已发生更改。 After I opened the file from the project folder, the option for Build > flutter > Build Bundle(s) /APK > Build App Bundle finally reappeared again.从项目文件夹中打开文件后,Build > flutter > Build Bundle(s) /APK > Build App Bundle 的选项终于再次出现。 Just sharing my experience and hope it can help someone else who may come across this rather strange issue.只是分享我的经验,希望它可以帮助可能遇到这个相当奇怪问题的其他人。

Reopen the project from your projects directory, not from recent projects option.从您的项目目录重新打开项目,而不是从最近的项目选项。 This solved for me这为我解决了

Please follow these steps:-请按照以下步骤操作:-

Go To Project Structure>Project>NOSDK转到Project Structure>Project>NOSDK

Change NOSDK to the latestNOSDK更改为最新

ANDROID API PLATFORM

Then go to MODULE and DO THE SAME然后转到MODULE并执行DO THE SAME

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

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