13

I installed Flutter and Android Studio following this link here: 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.

Android Studio: 3.3.2

CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
Chris
  • 413
  • 1
  • 4
  • 12
  • what happens when you use the command line with `flutter build apk` ? – Mazin Ibrahim Apr 05 '19 at 16:25
  • Mazin Ibrahim, thank you very much for your help. Following yours and CopsOnRoad's tip, I used that command and it worked perfectly :) Thank you, sir! – Chris Apr 07 '19 at 10:31

4 Answers4

19

You can't build apk using Build option in Android Studio if you are running your Flutter project.

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)

  2. Open your module in Android Studio and you can use Build option of the Android studio to build the debug 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.

enter image description here

CopsOnRoad
  • 237,138
  • 77
  • 654
  • 440
  • 1
    CopsOnRoad, thank you so much for your explanations and solutions. I added flutter to path and tried your first solution: Works like a charme :) Appreciate your help! – Chris Apr 07 '19 at 10:30
  • @CopsOnRoad In my case its not showing to Open for Editing in Android Studio – Arbaz kdr May 21 '21 at 04:27
4

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. 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. After I opened the file from the project folder, the option for Build > flutter > Build Bundle(s) /APK > Build App Bundle finally reappeared again. Just sharing my experience and hope it can help someone else who may come across this rather strange issue.

1

Reopen the project from your projects directory, not from recent projects option. This solved for me

Apoorv Pandey
  • 2,118
  • 2
  • 11
  • 13
0

Please follow these steps:-

Go To Project Structure>Project>NOSDK

Change NOSDK to the latest

ANDROID API PLATFORM

Then go to MODULE and DO THE SAME

Dharmbir Singh
  • 17,485
  • 5
  • 50
  • 66