flutter package

Reprinted from: https:? //Www.jspang.com/detailed id = 44 # toc221

Configuring APP icon

APP want to configure the picture, you need to find the following directories:

Project root directory / android / app / src / main / res /

After entering you will see a lot mipmap- prefixed named folder, behind is the pixel density, we can see the resolution of the icon.

  • mdpi (in) ~ 160dpi
  • hdpi (high) ~ 240dip
  • xhdpi (ultra) ~ 320dip
  • xxhdpi (Super Ultra) ~ 480dip
  • xxxhdpi (Ultra Ultra) ~ 640dip

The pixel density of the corresponding picture into the corresponding folder, remember to use png format picture, to remember the name of unity, to be configured once.

AndroidManifest.xml file

This file is mainly used to configure the name of APP, icons and system privileges, the directory is located at:

Project root directory /android/app/src/main/AndroidManifest.xml

android:label="flutter_app"   //配置APP的名称,支持中文
android:icon="@mipmap/ic_launcher" //APP图标的文件名称

Generated keystore

Pits here with a lot of small partners must pay attention to. Official written in very simple, just run the following code in a terminal can be successful, but the truth is being given.

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

Screenshot being given as follows:

alt

Could not find this directory, really pit, in fact, we just did not configure the environment variables. But to a package configuration environment variable is not known.

This time you can use the following command to find keytool.exe position.

flutter doctor -v

alt

This time you copy the command and direct input, but here too there is a pit, that is, if the folder with the middle empty, you need to use the quotation marks expansion.

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

This may be yet? Then you are too naive, or error.

alt

The main problem is the wrong directory does not exist and does not have write permissions, so we have to replace a write permission. We changed the order form below.

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

This time it can create success. D below your disk will have a file Jks, remember this file can not be shared with anyone.

With this key.jks file, you can go to the project directory androidfolder, create a file named key.properties and open paste the following code.

storePassword=<password from previous step>    //输入上一步创建KEY时输入的 密钥库 密码
keyPassword=<password from previous step> //输入上一步创建KEY时输入的 密钥 密码 keyAlias=key storeFile=<E:/key.jks> //key.jks的存放路径

My final document like this:

storePassword=123123
keyPassword=123123
keyAlias=key storeFile=D:/key.jks

This work and do not share it, oh, this Key. Even if successful.

Configuration key registration

After the key generation is good, need to be configured in build.gradle file. This process is very simple, is to copy and paste something, you do not need to know the specific use of these files.

Item One:

/Android/app/build.gradle file into the project directory, in android{front of this line, add the following code:

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

The following code is replaced

buildTypes {
    release {
        signingConfig signingConfigs.debug
    }
}

Replacing code:

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

Generated apk

Direct input terminal:

flutter build apk

Guess you like

Origin www.cnblogs.com/pp-pping/p/12167733.html