Hello Friends, Today I am going to tell you about how to build a release app bundle in android studio for the flutter project, it is very simple to export a release bundle.
If you want to Export a project from android studio, then the method is the same as, we export the android java project export release app bundle in android studio, but in the case of a flutter the method is slightly different.
What is Different Between Java and Flutter Project?
Java and Flutter both are programming languages, and you can use these programming languages to create android applications! If you are using Flutter Programming language, which is google official programming language, you can create web apps, ios apps, and android apps.
How to Build Flutter Android App Bundle
First Create your flutter project and run your application, if your application is fine then you are ready for the export project, otherwise, your application created some problems in rendering your project,
There are 2 Types of Rendering Processes
- You Are Creating a Fresh Flutter Project
- You Are Export Project for Existing Project
You are Rendering for Fresh Flutter Project
After the create your application in flutter then a big problem to render your app bundle, because of no specific option for rendering your project in the flutter environment, in the java case give a specific option for rendering your project with generate key store. the main problem is creating a store key.
Follow these steps to render your fresh project
- Your application is completed then first create a release apk to check your app is working fine. Build>> Flutter>>Build APK
- If Your application is working fine then you are ready to render your final app bundle by creating a store key,
- Go option menu and click on the Tools option then find the Flutter option then right-click and choose Open for editing in android studio
- After that follow the same process as for the java project and you get your final app bundle.
- you can publish your application in the google play console.
Follow these steps to render your Existing Project
If you want to update your previous application or replace app to flutter app then you should use previous package name or keystore and password. I will tell you process step by step, and you can follow and update your application successfully.
- Import your code and change the package name and logo other activities and complete your application
- after that open build.gradle and create a new property in app folder in android app
Open Project >> android >> build.gradle
and Paste some code in build.grade file after apply plugin code
How to Implement Unity Ads in Android Studio Projects Banner or Interstitial Ads
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
after that paste final code in build.gradle file after defaultConfig
signingConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null // original code //storeFile file("key.jks") ? file("key.jks") : null //new solution for some customers storePassword keystoreProperties['storePassword'] } } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.release } }
How to Create key.properties in Flutter
if you want to create a key folder for using key credential for signing apk . Select android folder and Right Click and select new and Choose file and create your key.properties folder.
and Paste this code in key.properties file and save it,
storePassword=[email protected]
keyPassword=[email protected]
keyAlias=key0
storeFile=key.jks
Complete this work after that paste your keystore in android >> app paste your keystore and rename your key store to key.jks and render your application for budle apk.
Here are the steps to generate aab file
1. Create your Keystore
Keystore is the file you should have to sign your AAB file.
Run the following command in Terminal at your project's root directory.
keytool -genkey -v -keystore ttwenty.jks -keyalg RSA -keysize 2048 -validity 10000 -alias ttwenty
After entering this command, you will be asked to fill key's password and some information.
2. Create a reference file to Keystore
Create a file named key.properties at [project root]/android/
storePassword=password from previous step
keyPassword=password from previous step
keyAlias=ttwenty
storeFile=../../ttwenty.jks
if you create with different key alias, please specify it in keyAlias.
For storeFile if you choose to put Keystore file at the root of your Flutter's project directory. This file's path would work.
3. Modify app/build.gradle
Load keystore's properties
Open [project]/android/app/build.gradle, look for android block, and put following code at the top of its.
def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}
android {
...
}
Replace buildTypes block
find buildTypes block. it should look like the below:
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now,
// so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
you have to replace it with following code:
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
release {
signingConfig signingConfigs.release
}
}
4. Let's sign and build the release version
flutter clean
flutter pub get
flutter build appbundle
PLAYLIST : https://www.youtube.com/watch?v=i-5bw...
CODE and Assets : https://github.com/abidroid/t20_yt
keytool -genkey -v -keystore dukangardelivery.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key0