- Install
- Set up an editor
- Test drive
- Write your first Flutter app, part 1
- Learn more
- Flutter for Android developers
- Flutter for iOS developers
- Flutter for React Native developers
- Flutter for web developers
- Flutter for Xamarin.Forms developers
- Introduction to declarative UI
- Cookbook
- Codelabs
- Tutorials
- User interface
- Introduction to widgets
- Layouts in Flutter
- Layout tutorial
- Dealing with box constraints
- Adding interactivity to your Flutter app
- Adding assets and images
- Navigation & routing
- Introduction to animations
- Animations overview
- Animations tutorial
- Hero Animations
- Staggered Animations
- Advanced UI
- Slivers
- Taps, drags, and other gestures
- Widget catalog
- Data & backend
- State management
- State management
- Start thinking declaratively
- Differentiate between ephemeral state and app state
- Simple app state management
- List of state management approaches
- JSON and serialization
- Firebase
- Accessibility & internationalization
- Accessibility
- Internationalizing Flutter apps
- Platform integration
- Writing custom platform-specific code
- Packages & plugins
- Using packages
- Developing packages & plugins
- Background processes
- Tools & techniques
- Android Studio / IntelliJ
- Visual Studio Code
- Upgrading Flutter
- Hot reload
- Code formatting
- Debugging Flutter apps
- Using OEM debuggers
- Flutter's build modes
- Testing Flutter apps
- Performance best practices
- Flutter performance profiling
- Creating flavors for Flutter
- Preparing an Android App for Release
- Preparing an iOS App for Release
- Continuous Delivery using fastlane with Flutter
- Bootstrap into Dart
- Inside Flutter
- Platform specific behaviors and adaptations
- Technical Overview
- Technical videos
- FAQ
- Flutter widget index
- Install
- Windows install
- MacOS install
- Linux install
- Set up an editor
- Write your first Flutter app, part 1
- Learn more
- Cupertino (iOS-style) widgets
- Layout widgets
- Animation and motion widgets
- Retrieve the value of a text field
- Basic widgets
- Material Components widgets
- Animate the properties of a Container
- Fade a Widget in and out
- Add a Drawer to a screen
- Displaying SnackBars
- Exporting fonts from a package
- Updating the UI based on orientation
- Using Themes to share colors and font styles
- Using custom fonts
- Working with Tabs
- Building a form with validation
- Create and style a text field
- Focus on a Text Field
- Handling changes to a text field
- Retrieve the value of a text field
- Adding Material Touch Ripples
- Handling Taps
- Implement Swipe to Dismiss
- Display images from the internet
- Fade in images with a placeholder
- Working with cached images
- Basic List
- Create a horizontal list
- Creating a Grid List
- Creating lists with different types of items
- Place a floating app bar above a list
- Working with long lists
- Report errors to a service
- Animating a Widget across screens
- Navigate to a new screen and back
- Navigate with named routes
- Pass arguments to a named route
- Return data from a screen
- Send data to a new screen
- Fetch data from the internet
- Making authenticated requests
- Parsing JSON in the background
- Working with WebSockets
- Persist data with SQLite
- Reading and Writing Files
- Storing key-value data on disk
- Play and pause a video
- Take a picture using the Camera
- An introduction to integration testing
- Performance profiling
- Scrolling
- An introduction to unit testing
- Mock dependencies using Mockito
- An introduction to widget testing
- Finding widgets
- Tapping, dragging and entering text
- Development
- Introduction to widgets
- Layout tutorial
- Dealing with box constraints
- Adding interactivity to your Flutter app
- Adding assets and images
- Navigation & routing
- Navigate to a new screen and back
- Send data to a new screen
- Return data from a screen
- Navigate with named routes
- Animating a Widget across screens
- AnimatedList
- Sample App Catalog
- Animations overview
- Animations tutorial
- Staggered Animations
- Slivers
- Taps, drags, and other gestures
- Accessibility widgets
- Assets, images, and icon widgets
- Async widgets
- Input widgets
- Interaction model widgets
- Painting and effect widgets
- Scrolling widgets
- Styling widgets
- Text widgets
- State management
- Start thinking declaratively
- Differentiate between ephemeral state and app state
- Simple app state management
- List of state management approaches
- JSON and serialization
- Accessibility
- Internationalizing Flutter apps
- Writing custom platform-specific code
- Using packages
- Fetch data from the internet
- Developing packages & plugins
- Background processes
- Android Studio / IntelliJ
- Set up an editor
- Flutter inspector
- Creating Useful Bug Reports
- Visual Studio Code
- Set up an editor
- Upgrading Flutter
- Hot reload
- Code formatting
Preparing an Android App for Release
During a typical development cycle, you test an app using flutter run
at the command line, the Run and Debug toolbar buttons in IntelliJ. By default, Flutter builds a debug version of your app.
When you’re ready to prepare a release version for Android, for example to publish to the Google Play Store, follow the steps on this page.
Review the App Manifest
Review the default App Manifest file AndroidManifest.xml
located in <app dir>/android/app/src/main
and verify the values are correct, especially:
application
: Edit theandroid:label
in theapplication
tag to reflect the final name of the app.uses-permission
: Remove theandroid.permission.INTERNET
permission if your application code does not need Internet access. The standard template includes this tag to enable communication between Flutter tools and a running app.
Review the build configuration
Review the default Gradle build file file build.gradle
located in <app dir>/android/app
and verify the values are correct, especially:
defaultConfig
:applicationId
: Specify the final, unique (Application Id)appidversionCode
&versionName
: Specify the internal app version number, and the version number display string. You can do this by setting theversion
property in the pubspec.yaml file. Consult the version information guidance in the versions documentation.minSdkVersion
&targetSdkVersion
: Specify the minimum API level, and the API level on which the app is designed to run. Consult the API level section in the versions documentation for details.
Adding a Launcher icon
When a new Flutter app is created, it has a default Launcher icon. To customize this icon you might want to check out the Flutter Launcher Icons package.
Alternatively, if you want to do it manually, here’s how:
Review the Android Launcher Icons guidelines for icon design.
In the
<app dir>/android/app/src/main/res/
directory, place your icon files in folders named using configuration qualifiers. The defaultmipmap-
folders demonstrate the correct naming convention.In
AndroidManifest.xml
, update theapplication
tag’sandroid:icon
attribute to reference icons from the previous step (for example,<application android:icon="@mipmap/ic_launcher" ...
).To verify the icon has been replaced, run your app using
flutter run
and inspect the app icon in the Launcher.
Signing the app
To publish on the Play store, you need to give your app a digital signature. Use the following instructions to sign your app.
Create a keystore
If you have an existing keystore, skip to the next step. If not, create one by running the following at the command line: keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
Note: Keep this file private; do not check it into public source control.
Note: keytool
might not be in your path. It is part of the Java JDK, which is installed as part of Android Studio. For the concrete path, run flutter doctor -v
and see the path printed after ‘Java binary at:’, and then use that fully qualified path replacing java
with keytool
.
Reference the keystore from the app
Create a file named <app dir>/android/key.properties
that contains a reference to your keystore:
storePassword=<password from previous step>
keyPassword=<password from previous step>
keyAlias=key
storeFile=<location of the key store file, e.g. /Users/<user name>/key.jks>
Note: Keep this file private; do not check it into public source control.
Configure signing in gradle
Configure signing for your app by editing the <app dir>/android/app/build.gradle
file.
- Replace:
android {
with the keystore information from your properties file:
def keystoreProperties = new Properties() def keystorePropertiesFile = rootProject.file('key.properties') if (keystorePropertiesFile.exists()) { keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) } android {
- Replace:
buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } }
with:
signingConfigs { release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile file(keystoreProperties['storeFile']) storePassword keystoreProperties['storePassword'] } } buildTypes { release { signingConfig signingConfigs.release } }
Release builds of your app will now be signed automatically.
Enabling Proguard
By default, Flutter does not obfuscate or minify the Android host. If you intend to use third-party Java or Android libraries, you may want to reduce the size of the APK or protect that code from reverse engineering.
For information on obfuscating Dart code, see Obfuscating Dart Code in the Flutter wiki.
Step 1 - Configure Proguard
Create /android/app/proguard-rules.pro
file and add rules listed below.
#Flutter Wrapper
-keep class io.flutter.app.** { *; }
-keep class io.flutter.plugin.** { *; }
-keep class io.flutter.util.** { *; }
-keep class io.flutter.view.** { *; }
-keep class io.flutter.** { *; }
-keep class io.flutter.plugins.** { *; }
The configuration above only protects Flutter engine libraries. Any additional libraries (for example, Firebase) require their own rules to be added.
Step 2 - Enable obfuscation and/or minification
Open /android/app/build.gradle
file and locate buildTypes
definition. Inside release
configuration set minifiyEnabled
and useProguard
flags to true. You have to also point ProGuard to the file you have created in step 1.
android {
...
buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Note: Obfuscation and minification can considerably extend compile time of the Android application.
Building a release APK
This section describes how to build a release APK. If you completed the signing steps in the previous section, the release APK will be signed.
Using the command line:
cd <app dir>
(replace<app dir>
with your application’s directory).- Run
flutter build apk
(flutter build
defaults to--release
).
The release APK for your app is created at <app dir>/build/app/outputs/apk/release/app-release.apk
.
Installing a release APK on a device
Follow these steps to install the APK built in the previous step on a connected Android device.
Using the command line:
- Connect your Android device to your computer with a USB cable.
cd <app dir>
where<app dir>
is your application directory.- Run
flutter install
.
Publishing an APK to the Google Play Store
For detailed instructions on publishing the release version of an app to the Google Play Store, see the Google Play publishing documentation.
Building a release app bundle
This section describes how to build a release app bundle. If you completed the signing steps in the previous section, the release bundle will be signed.
From the command line:
- Enter
cd <app dir>
. (Replace<app, dir>
with your application’s directory.) - Run
flutter build appbundle
. (Runningflutter build
defaults to a release build.) - To generate a different variant of bundle, you can enter `flutter build appbundle --release --target-platform=android-arm`.
This generates a bundle for android-arm.
The release bundle for your app is created at <app dir>/build/app/outputs/bundle/release/app.aab
.
Testing an app Bundle
An app bundle can be tested in multiple ways. This section describes a couple ways in which to test an app bundle.
Offline using the bundle tool
- If you have done done so already, download
bundletool
from the GitHub repository. - Generate a set of APKs from your app bundle.
- Deploy the APKs to connected devices.
Online using Google Play
- Upload your bundle to Google Play to test it. You can use the internal test track, or the alpha or beta channels to test the bundle before releasing it in production.
- Follow these steps to upload your bundle to the Play Store.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论