How to build signed apk from Android Studio for Flutter
Step-1
In Android Studio's tab bar, click on Tools
and then Flutter
and then Open Android module in Android Studio
:
Step-2
Open Project it in New Window:
Step-3
Having opened the project, click on Build
and then Generate Signed Bundle / APK ...
For create/generate Signed APK using Android Studio version 3.5.1 for Flutter follow the following steps -
Step 1 :
Go to in your project & then Tools -> Flutter -> Open for Editing in Android Studio as shown below
Then Select New Window option as shown below
Step 2 :
Wait for while until project synchronization. After that
Go to Build -> GenerateSigned Bundle/APK... option from menu bar as shown bellow
Step 3 :
Select Android App Bundle or APK Option as per your need. (Android App Bundle is best solution) and click Next button.
Step 4 :
Select Create new.. option to generate new Signed key (When you release your app First Time)
Step 5 :
Fill all options as follow
Note -
Key store Path -
Path where your key store file i.e .jks file stored (as shown in above image). [Best way Select the path within your project directory.]
Key store password -
Enter password e.g. 123456
Key alias -
Enter Key alias (Name of .jks file) e.g. key
Key Password -
Enter Key password (Choose different password than Key store password)e.g. key123456
Validity(years) -Keep it as it is or change as per your requirements.
Certificate -
Fill certificate information (Not all fields are mandatory)
Then click OK and you will get following screen...
Step 6 -
Step 7 -
Click Next button and you will get following screen...
Select options
Build variants - release and
Signature versions both V1 and V2 respectively as shown above screen shot and click Finish button.
Step 8 -
Wait for a while until Gradle Build Running process complete as shown below...
and finally you will get the Generate Signed APK : (APKs) generated successfully .from that click on Locate option to get Location of your Generate Signed APK Key. as shown bellow.
That's it you generated Signed APK successfully for your Flutter project.
IMPORTANT:
Please DO NOT lose the key and its all information i.e. Key store path,Key store password, Key alias and Key password (Best way write down it in to the note book or make text file and store on your drive while generating it.). Without this, you won't be able to update your application because the new release will need to be signed with the same key.
I hope you will get detailed information.
Instead of using Android Studios UI you could easily also just use a command prompt. This way was way easier for me, cause I had many issues creating a signed apk by using the ui.
Before you create the signed APK you must prepare your project.
1. Add Flutter automation dependencies to your pubspec.yaml
dependencies: flutter: sdk: flutter flutter_automation: ^1.1.4
Currently ^1.1.4 is the newest dependency, this will eventually change.
2. Get the new dependency
Run flutter packages get
in your command prompt in your projects directoy
3. Setup the signing
Run flutter pub pub run flutter_automation --android-sign
in your command prompt.Then you will be asked to input
- a key alias,
- your certificate information ( CN=First and Last Name (??), OU=Organizational Unit, O=Organization, L=City or Locality, S=State or Province, C=Country Code (XX)
- a key password
- and a keystore password
4. Generate your signed apk or bundle
Simply run flutter build apk --release
or flutter build bundle --release
to generate a signed apk/bundle of your app.