link
- IOS 3 minutes to achieve custom Xcode initialization template, improve development efficiency
- Make your own Pod library from 0
Note:
- The packaging process documented here is all done on VSCode, as is Android Studio.
- This time use Gradle configuration packaging
1. Check & install JDK
- Check the current JDK version number
java -version
If the current Java version is displayed, the JDK is successfully installed or has been installed before. If the JDK has been installed, skip the following installation steps
- Install the JDK
If brew cask install oracle-JDK is displayed, the installation is successful. Because I need to update Homebrew, I use the download and install method from the official website.
- JDK official website download address, download the corresponding version, mine is MBP, so choose
macOS Installer
- After the installation is successful, open the environment configuration file with terminal:
vim .bash_profile
, an increase ofexport JAVA_HOME=$(/usr/libexec/java_home)
- Save and exit
esc -> wq
. - perform
source .bash_profile
Update the configuration file and make it take effect - Check the JDK version number to see if it is successful
2. Generate the signature certificate.jks
The main functions of using a signature are:
- Application upgrade: The system will only allow the installation of upgraded applications if the same certificate is signed. If you use a different certificate, your application will be required to use a different package name, which in this case is equivalent to installing a completely new application. If you want to upgrade the application, the signing certificate must be the same, and the package name must be the same!
- Application modularization: The Android system can allow multiple applications with the same certificate signature to run in a process. The system actually treats them as a single application. At this point, our application can be deployed as modules, and users can independently upgrade one of the modules.
- Code or data sharing: Android provides signature-based permissions so that one application can expose its functionality to another application signed with the same certificate. By signing multiple applications with the same certificate, you can share code and data between applications in a secure way with signature-based permission checks.
** Note ** : Once you have signed your Apk online, you must not lose your signature file, password, alias, etc., or you will run away.
Replace the path where the certificate was generated with your own and run the following command on the terminal
JKS -keyalg RSA -keysize 2048 -validity 10000 -alias signCopy the code
- Genkey: generates a key
- Keystore:
- < store path >/sign. JKS: store path and name of the certificate
- Keyalg rsa-keysize 2048: encrypts signatures using the 2048-bit RSA algorithm
- Validity 10000: validity period, in this case 10000 days
- Alias sign: indicates the alias sign
According to the steps, according to the actual situation, enter the content, after generating the signature certificate path is your command path above
3. Configure the package file
- Import the certificate created above. If the key folder does not exist, create one
< > flutter project/android/app/key/sign JKSCopy the code
- Create the key.properties file
< Flutter project >/android/key.propertiesCopy the code
Add configuration, you can copy the existing properties file, change the name and corresponding content,
storePassword=android
keyPassword=123456
keyAlias=sign
storeFile=key/sign.jks
Copy the code
- StorePassword:
- KeyPassword: generates the keystore password for the signature certificate input
- KeyAlias: alias of the certificate
- StoreFile: path of the certificate relative to key.properties
- Configure the build.gradle file
def keystorePropertiesFile = rootProject.file("key.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
signingConfigs {
release {
keyAlias 'sign'
keyPassword 'android'
storeFile file('key/sign.jks')
storePassword 'android'
}
}
Copy the code
4, VSCode final directory configuration
The Flutter package generates APK
- Enter in terminal in VSCode
flutter build apk
, if the final display✓ Built * * *
“, the package is successfully packaged build/app/outputs/flutter-apk/app-release.apk
Is the subpath in the project, by this point, APK packaging has been successful.