📅  最后修改于: 2023-12-03 15:00:47.614000             🧑  作者: Mango
As a programmer working with Flutter, you will need to export your app as an APK file to distribute your app to Android devices. In this guide, we will cover the steps to export your Flutter app as an APK file.
Before exporting your app, you should have completed the following:
To export your Flutter app as an APK file, follow these steps:
Open your Flutter project folder in the terminal or command prompt.
Run the following command to build your app:
flutter build apk --split-per-abi
This command will build your app and create separate APK files for each Android architecture (arm64-v8a, armebi-v7a, and x86_64). These APK files are located in the build/app/outputs/flutter-apk
directory of your project.
Once the build is complete, you can find the APK files in the build/app/outputs/flutter-apk
directory of your project.
If you plan to publish your app on the Google Play Store, you need to sign the APK files. You can sign the APK files using a keystore file, which contains your app's private key. You can generate a keystore file using the following command:
keytool -genkey -v -keystore myapp.keystore -alias myalias -keyalg RSA -keysize 2048 -validity 10000
This command will generate a keystore file called myapp.keystore
and create a private key with the alias myalias
. You can use this keystore file to sign your APK files.
To sign your APK files using the keystore file, run the following command:
jarsigner -verbose -sigalg SHA256withRSA -digestalg SHA-256 -keystore myapp.keystore app-armeabi-v7a-release.apk myalias
This command will sign the APK file with the alias myalias
in the myapp.keystore
file.
Once your app is signed, you can verify the signature using the following command:
jarsigner -verify -verbose -certs app-armeabi-v7a-release.apk
This command will confirm that the APK file is signed correctly.
Congratulations! You have successfully exported your Flutter app as an APK file. You can now distribute your app to Android devices using the APK files. If you plan to publish your app on the Google Play Store, you can now upload your APK files to your Google Play Console account.