Build and release an Android app

 When you’re ready to prepare a release version of your app, for example, to publish to the Google Play Store, this page can help. Before publishing, you might want to put some finishing touches on your app. This page covers the following topics:


Create an upload keystore

Step 1 Go to  in android studio then


  • Following the Android Studio key generation steps
  • Running the following at the command line:

    On Mac/Linux, use the following command: 

  •   keytool -genkey -v -keystore ~/upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias upload

         On Windows, use the following command:
        
        keytool -genkey -v -keystore c:\Users\Praveen\key.jks -storetype JKS -keyalg RSA -keysize 2048 -validity 10000 -alias key      -----type this command in terminal 




Like this Ex---->
PS C:\Users\Praveen\AndroidStudioProjects\pahelia> keytool -genkey -v -keystore c:\Users\Praveen\key.jks -storetype JKS
 -keyalg RSA -keysize 2048 -validity 10000 -alias key
Enter keystore password:
Re-enter new password:
What is your first and last name?
  [Unknown]:  Praveen Suthar
What is the name of your organizational unit?
  [Unknown]:  1
What is the name of your organization?
  [Unknown]:  Vishwakarma Technolabs
What is the name of your City or Locality?
  [Unknown]:  Banswara
What is the name of your State or Province?
  [Unknown]:  Rajasthan
What is the two-letter country code for this unit?
  [Unknown]:  91
Is CN=Praveen Suthar, OU=1, O=Vishwakarma Technolabs, L=Banswara, ST=Rajasthan, C=91 correct?
  [no]:  yes




this location generates the file

Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12 which is an industry standard format
 using "keytool -importkeystore -srckeystore c:\Users\Praveen\key.jks -destkeystore c:\Users\Praveen\key.jks -deststore
type pkcs12".



Reference the keystore from the app

Create a file named [project]/android/key.properties that contains a reference to your keystore:

storePassword=123456
keyPassword=123456
keyAlias=key
storeFile=c:\Users\Praveen\key.jks


Configure signing in gradle

Configure gradle to use your upload key when building your app in release mode by editing the [project]/android/app/build.gradle file.

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"



def keystoreProperties = new Properties()
def keystorePropertiesFile = rootProject.file('key.properties')
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
}


android {
compileSdkVersion flutter.compileSdkVersion

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.pstech.newpuzzle2023"
minSdkVersion 19
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
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
}
}
}

flutter {
source '../..'
}

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:31.1.0')
implementation 'com.google.firebase:firebase-analytics'
}


then all type this cammand in terminal

PS C:\Users\Praveen\AndroidStudioProjects\pahelia> flutter clean

PS C:\Users\Praveen\AndroidStudioProjects\pahelia> flutter build apk --release






    
Thank you!
    


Comments

Popular posts from this blog

Unlocking the Power of OOP: A Beginner's Guide to Objects, Encapsulation, Inheritance, Abstraction, and Polymorphism

HTTP GET Response in Flutter

Building a Flutter Firebase Firestore CRUD App