Packaging apk

1. Modify the AndroidManifest. XML

2. Application signature

On macOS or Linux, run the following command without modification

keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
Copy the code

You need to install a Java SDK, can go to the website to download, this machine is the use: link: pan.baidu.com/s/1GfSMPnZA… Password: KLWQ

After that, enter all kinds of passwords, passwords, names, countries and so on

3. Create a key. The properties

Path: /android/key.properties File manually created

storePassword = 123456
keyPassword = 123456
keyAlias = key
storeFile = /Users/asdc/Documents/project/localproj/flutter/key.jks
Copy the code

4. Configure signatures in Gradle

By editing/android/app/build. Gradle file for our app configuration signature:

Find the Android code block:

android {
  ...
}
Copy the code

Add before

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

Comment out the buildTypes code block and add later

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
        }
    }
Copy the code

5. Package the application and run the terminal

flutter build apk
Copy the code

The appendix

1. zsh: command not found: flutter

Single solution: Run the following command on the Android Studio terminal

source ~/.bash_profile
Copy the code
Android Studio package error: App :lintVitalRelease

Next to the Android code section in Step 4, add the following code

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
Copy the code

Refer to the link

3. ZSH: Command Not Found: Android Studio failed to pack :app:lintVitalRelease