How can I build the apk from android studio from flutter - android-studio

now I'm making an app using flutter and trying to upload the app as internal test on Google play store. I saw people asking how to do it, but could not figure it out...
On the official document, it says "Build > Build > Generate Signed Bundle/APK" and I can generate APK, but I don't see the "Generate Signed Bundle/APK".
When I select "Build APK" in the picture above, it gives me the message like
You are building a fat APK that includes binaries for android-arm,
android-arm64, android-x64. If you are deploying the app to the Play
Store, it's recommended to use app bundles or split the APK to reduce
the APK size.
To generate an app bundle, run:
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
Learn more on: https://developer.android.com/guide/app-bundle
To split the APKs per ABI, run:
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
Learn more on: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...
27.9s ✓ Built build/app/outputs/apk/release/app-release.apk (19.2MB). Process finished with exit code 0
Also, I saw this chat (How to build signed apk from Android Studio for Flutter), but I cannot see "open android module in android studio"
Even when I opened the android project with different window, I cannot see the option as well..
it will be really helpful if someone can teach me how to generate the APK from my current situation...
Thank you so much..

The reason why Open Android module in Android Studio is missing under Tools > Flutter is likely because you're using an older version of Flutter DevTools on Android Studio. You can run flutter pub global activate devtools on the Terminal to update the DevTools installed on the machine as mentioned on this guide.

to build apk use this line in terminal
flutter build apk --release --no-sound-null-safety

Related

Android Studio doesn't start building Flutter project

I've installed Flutter, Dart their SDKs and Android Studio plugins everything needed for Flutter app development, as mentioned here:
https://flutter.dev/docs/get-started/install/windows
But when I go to generate a .apk by selecting Build->Flutter->BuildAPK, Android Studio simply does nothing. It doesn't even start building.
However, if I run command:
flutter build apk
It starts building project.
Any idea?
Well I found the answer.
File -> Settings -> Language & Frameworks -> Flutter
Flutter SDK Path was not set here. When I set appropriate path, it started building.

Android Studio's Play button is not enabled

I am completely new to flutter. I am trying to build https://github.com/flutter/udacity-course/tree/master/course/02_category_widget/task_02_category_widget but the Play Button won't enable.
I tried creating an APK of the project from the command line:
flutter build apk
and
flutter install
It creates an APK and runs on my Android device. I also tried creating a new Flutter Project and the Play button is working well on that. What am I missing in this project?
Check by running flutter doctor if you have everything installed
Check that Android Studio knows where your Flutter SDK is located. File->Settings->Languages and Frameworks->Flutter

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
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
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.
In terminal, write flutter build apk (this will build apk for release version not the debug version)
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.
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.
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
Change NOSDK to the latest
ANDROID API PLATFORM
Then go to MODULE and DO THE SAME

Flutter How to make release version in Android Studio?

By default Android Studio use debug mode when building Flutter application. You can build the release version with the command line, see How to optimize the Flutter App size?
flutter build apk --release
Now: how to configure Android Studio to do the same, when I run the application (Shift+F10)? I can't find this setting...
You have to edit the run configuration:
Open the run configuration:
Add the --release flag:
Note that using the --release flag is not supported when you build with the Android Emulator.
In Android Studio , click on :
> Run
> Flutter Run 'main.dart' in Release Mode
flutter build appbundle --release --build-name=1.1.1 --build-number=3
Or you can run that in your Terminal, Remember to change build name and build number to corresponding values of your release app versioning.
as the green play button in toolbar runs the debug mode, i switched it to release mode via:
Right click Play Icon in toolbar -> Customize Toolbar
click "+", chose Add Action
chose "Plugins/Flutter/Run in Flutter release mode"
Delete the old Play button by selecting it and click "-"
The best way to make your apk for release mode is that open the project -> click on the android folder then make your apk as same as generated application build in android using your .jks key and alias password and name. this is the correct way for making apk in flutter.

Flutter: Android build for deployment

How can I create/prepare Android build for deployment on Appstore, using Android Studio? (I've developer account singed app and keys/credential)
What are step and checklist, required to create Android deployment build for flutter project
They have provided all the steps over here
Preparing an Android App for Release.
And for project You can set all common settings in pubspec.yaml file.
To build an android release of your project.
1. Using the GUI (AndroidStudio)
As shown in the image below, in your Android Studio action bar click on build and then select flutter and choose the type of build you want;
Build Apk
Well, for example when you want to test your app outside of google play store.
Build App bundle
Recommended when you want to publish your app on playstore
2. Using the CLI (Terminal, Cmd )
Open the terminal and navigate to the root folder of your project and then tape the following command;
flutter build apk
or
flutter build appbundle
After the build you'll see a message like this :
Running Gradle task 'assembleRelease'... 191.3s
✓ Built build/app/outputs/flutter-apk/app-release.apk (32.1MB).
This means everything is fine, so go to the build folder in your project's root folder to access your final app file.
For more details, Please use the official documentation guidelines : https://docs.flutter.dev/deployment/android.

Resources