Flutter Android Client Packager

You want to install on the phone, must be packaged, because there is no Apple phone, it can only be packaged apk Android client.

Check the App Configuration

Review the default application manifest file (located /android/app/src/main/in the AndroidManifest.xmlfile), and verify that the values are correct, in particular:

android: name label of this project is packaged
android: icon pack icon that is generated, you can replace or change the name

Create a keystore

Written on official documents yes, please create one by running the following command: keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

But we will complain after the knock, follow the prompts to run flutter doctor still did not see the crux of the problem. After reading other people step on pit documents, should be run:

flutter doctor -v

You can see some of the following codes:

Find on the map Java binary at: behind the address, and then copied to the front of the official position of command, as follows:

D:\Program Files\Android\Android Studio\jre\bin\keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

After the carriage return or find an error, later found to be no spaces in the path, if there is space, then, to add quotation marks:

D:\'Program Files'\'Android\Android Studio'\jre\bin\keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

NOTE : ~ / key.jks Key is to be stored in location, it can be changed to your existing letter path, such as: d: \ key.jks or e: \ key.jks

D:\'Program Files'\Android\'Android Studio'\jre\bin\keytool -genkey -v -keystore e:\key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key

After the carriage return will let you enter the key store password, this can easily enter, followed by instructions on it.

Cited in the application keystore

Create a directory called android in the  key.properties document, which copy the following contents:

// such as your key password is 123456 
storePassword = 123456   // key password 
keyPassword = 123456   // key password 
keyAlias = Key 
StoreFile = E: /key.jks   // storage location key

Note : keep the file secret; do not add it to the common source control

In the Configure Signature gradle

By editing the android/app/build.gradlefile for the application configuration signature

1, replacing

Found android {...}, then add the following code above:

def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

2, replacing

Found buildTypes {...}, then the entire with the following code:

signingConfigs {
    release {
        keyAlias keystoreProperties['keyAlias']
        keyPassword keystoreProperties['keyPassword']
        storeFile file(keystoreProperties['storeFile'])
        storePassword keystoreProperties['storePassword']
    }
}
buildTypes {
    release {
        signingConfig signingConfigs.release
    }
}

Now, your release version of the application will automatically be signed.

Build a release version (release) APK

Now preparations are almost complete and can be packaged. input the command:

flutter build apk

Just a moment of time will be prompted to complete the package, and tell you where to store the apk.

Then you can install a real machine, or shared.

Guess you like

Origin www.cnblogs.com/joe235/p/11198759.html