text
stringlengths
1
474
For more information, check out the module-level build
section in the Gradle build file.<topic_end>
<topic_start>
Building the app for release
You have two possible release formats when publishing to
the Play Store.info Note
The Google Play Store prefers the app bundle format.
For more information, check out
About Android App Bundles.<topic_end>
<topic_start>
Build an app bundle
This section describes how to build a release app bundle.
If you completed the signing steps,
the app bundle will be signed.
At this point, you might consider obfuscating your Dart code
to make it more difficult to reverse engineer. Obfuscating
your code involves adding a couple flags to your build command,
and maintaining additional files to de-obfuscate stack traces.From the command line:The release bundle for your app is created at
[project]/build/app/outputs/bundle/release/app.aab.By default, the app bundle contains your Dart code and the Flutter
runtime compiled for armeabi-v7a (ARM 32-bit), arm64-v8a
(ARM 64-bit), and x86-64 (x86 64-bit).<topic_end>
<topic_start>
Test the app bundle
An app bundle can be tested in multiple ways.
This section describes two.<topic_end>
<topic_start>Offline using the bundle tool
<topic_end>
<topic_start>Online using Google Play
<topic_end>
<topic_start>
Build an APK
Although app bundles are preferred over APKs, there are stores
that don’t yet support app bundles. In this case, build a release
APK for each target ABI (Application Binary Interface).If you completed the signing steps, the APK will be signed.
At this point, you might consider obfuscating your Dart code
to make it more difficult to reverse engineer. Obfuscating
your code involves adding a couple flags to your build command.From the command line:Enter cd [project].Run flutter build apk --split-per-abi.
(The flutter build command defaults to --release.)This command results in three APK files:Removing the --split-per-abi flag results in a fat APK that contains
your code compiled for all the target ABIs. Such APKs are larger in
size than their split counterparts, causing the user to download
native binaries that are not applicable to their device’s architecture.<topic_end>
<topic_start>
Install an APK on a device
Follow these steps to install the APK on a connected Android device.From the command line:<topic_end>
<topic_start>
Publishing to the Google Play Store
For detailed instructions on publishing your app to the Google Play Store,
check out the Google Play launch documentation.<topic_end>
<topic_start>
Updating the app’s version number
The default version number of the app is 1.0.0.
To update it, navigate to the pubspec.yaml file
and update the following line:version: 1.0.0+1The version number is three numbers separated by dots,
such as 1.0.0 in the example above, followed by an optional
build number such as 1 in the example above, separated by a +.Both the version and the build number can be overridden in Flutter’s
build by specifying --build-name and --build-number, respectively.In Android, build-name is used as versionName while
build-number used as versionCode. For more information,
check out Version your app in the Android documentation.When you rebuild the app for Android, any updates in the version number
from the pubspec file will update the versionName and versionCode
in the local.properties file.<topic_end>
<topic_start>
Android release FAQ
Here are some commonly asked questions about deployment for
Android apps.<topic_end>
<topic_start>
When should I build app bundles versus APKs?
The Google Play Store recommends that you deploy app bundles
over APKs because they allow a more efficient delivery of the
application to your users. However, if you’re distributing
your application by means other than the Play Store,
an APK might be your only option.<topic_end>
<topic_start>
What is a fat APK?
A fat APK is a single APK that contains binaries for multiple
ABIs embedded within it. This has the benefit that the single APK
runs on multiple architectures and thus has wider compatibility,
but it has the drawback that its file size is much larger,
causing users to download and store more bytes when installing
your application. When building APKs instead of app bundles,
it is strongly recommended to build split APKs,
as described in build an APK using the
--split-per-abi flag.<topic_end>
<topic_start>
What are the supported target architectures?
When building your application in release mode,
Flutter apps can be compiled for armeabi-v7a (ARM 32-bit),
arm64-v8a (ARM 64-bit), and x86-64 (x86 64-bit).
Flutter supports building for x86 Android through ARM emulation.<topic_end>
<topic_start>
How do I sign the app bundle created by flutter build appbundle?
See Signing the app.<topic_end>
<topic_start>
How do I build a release from within Android Studio?
In Android Studio, open the existing android/
folder under your app’s folder. Then,
select build.gradle (Module: app) in the project panel:Next, select the build variant. Click Build > Select Build Variant
in the main menu. Select any of the variants in the Build Variants
panel (debug is the default):The resulting app bundle or APK files are located in
build/app/outputs within your app’s folder.
<topic_end>