I just finished an application with flutter and while I run it in debug mode everything is fine, but when I switch to --profile or --release mode it changes all the icons that I use and puts others, even the navigation arrows of the application.
I've had this error before while locally testing on a device with an .apk file directly generated from flutter build.
It fixed itself once I tested from the play store.
I found that when directly testing flutter build .apk files, there are issues as there are different processor types armeabi-v7a (ARM 32-bit), arm64-v8a (ARM 64-bit), and x86-64 (x86 64-bit).
If you are testing locally I would recommend:
Building an app bundle using flutter build appbundle in
terminal.
Using the bundletool from the GitHub repository.
Generate a set of APKs from your app bundle.
Deploy the APKs to connected devices.
Source
Related
Why the size of flutter build apk --release is larger than the size of flutter run --release which reduces the size by half. I need to get the leaner app size.
We should know that flutter run --release compiles only for a target ABI (because you run the generated APK directly to your device). while, flutter build apk --release results in a fat APK (Universal apk) that contains your code compiled for all the target ABIs, as a result, you could install this apk on any device.
Flutter app can be compiled for
Armeabi-v7a (ARM 32-bit)
Arm64-v8a (ARM 64-bit)
x86-64 (x86 64-bit)
In Flutter, a build refers to the process of taking your source code and turning it into a deployable app. There are two types of builds in Flutter: debug builds and release builds.
Debug builds are used for development and testing. They are built with debugging symbols enabled, which makes it easier to debug your code. Debug builds also include a debugger that allows you to pause the execution of your code and inspect variables and the call stack.
Release builds are used for deploying your app to app stores or distributing it to users. They are built with debugging symbols stripped, which makes the app smaller and faster. Release builds also have optimizations enabled, which makes the app even faster.
To create a release build in Flutter, you can use the flutter build command with the --release flag. For example:
flutter build apk --release
This will create a release build of your app in the build/app/outputs/apk directory.
Just rebuilt React Native app as the previous version failed in building on Android emulator. The React Native is upgraded from 0.66 to 0.67 and a few other modules, such as React Native gesture handler, were upgraded as well.
The app works fine on Android 2021.1.1 Patch 2 emulator. However after downloading the release package from the distribution server, the app installed on Android 10 device quits as soon as launching without giving any error.
What is the problem with the release package? Here is the build steps:
./gradlew bundleRelease
bundletool build-apks to build mypackage.apks with signature.
unzip it into mypackage.apk
Connecting android device to dev Mac using USB cable, the app was launched successfully on the real device. And the app can be launched successfully late as well. I notice that the size of the app is 77MB which is about twice as big as the app installed from the universal apk.
If you need to check apk on real device, follow this build steps:
Release APK Generation.
Place your terminal directory to Android using:
cd android
Then run the following command:
For Windows:
gradlew assembleRelease
For Linux and Mac OSX:
./gradlew assembleRelease
As a result, the APK creation process is done. You can find the generated APK at android/app/build/outputs/apk/app-release.apk. This is the actual app, which you can send to your phone or upload to the Google Play Store. Congratulations, you’ve just generated a React Native Release Build APK for Android.
There are frequent errors that show up in this process sometimes, which is typical to a React Native app, given React Native is continuously evolving. We are laying out here the most frequent React Native build errors that we ran into, to save you time and headaches.
I recently started working with flutter. I have been making several test applications. They all work well on emulators.
But now I want to be able to use them on my cell phone.
I took the APK that is generated when I run the application in the emulator, indicated in this route:
But it always fails to install
So far, my applications are simple, Hello world, Add numbers, etc.
Any ideas?
How should I do it correctly?
First: Open your Terminal/Shell/Command Line and open the directory of the Flutter App in there (cd PATH_TO_YOUR_FILE)
You probably want to create a profile-mode apk for testing. This build still helps debugging while having the speed of the --release version:
This creates a single APK which works on all devices (x64, arm64 and arm), it's probably pretty big:
flutter build apk --profile
If the people who install your App know which devices they have, you can use the split-per-abi command which creates three different APKs for all architectures (x64, arm64 and arm)
flutter build apk --profile --split-per-abi
If you want to have a release build, you can use what #Niteesh commented:
flutter build apk --release --split-per-abi
Release-builds can be uploaded to Google-Play (also the internal testing)
Read more: https://flutter.dev/docs/testing/build-modes
the apk that is generated when you run the app is the debug-apk, it contains lots of overheads which helps in flutter hot reload and hot restart. The size of debug apk version is also a lot.
use this command to generate release version of apk
flutter build apk --split-per-abi
After execution of the command, you get the path of the apk, something like this
√ Built build\app\outputs\flutter-apk\app-armeabi-v7a-release.apk (7.0MB).
Then you can install that apk on your phone
I need to understand the Android device architecture and, Why there is three different types of APKs are generated when I use:
flutter build apk --split-per-abi.
And when I use
flutter build apk
I get a large APK file called fat APK contains the 3 versions of the app.
The command flutter build apk --split-per-abi typically generates two APK files.
arm64 or x86_64 is the apk file for devices having 64-bit processors.
x86 is the apk file for 32-bit processors.
You can upload both of them on the PlayStore and based on the user's device architecture the corresponding apk will be installed.
The fat apk that you are getting while using the flutter build apk contains the necessary compiled code to target all the Application Binary Interfaces or ABIs. Once a user downloads this fat apk, then only the code applicable to the device will be used.
flutter build apk gives you large apk because,
flutter build apk 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.
--split-per-abi results in two APK files:
(The flutter build command defaults to --release.)
<app dir>/build/app/outputs/apk/release/app-armeabi-v7a-release.apk
<app dir>/build/app/outputs/apk/release/app-arm64-v8a-release.apk
Where armeabi-v7a for is 32-bit devices and arm64-v8a for 64-bit devices.
Read More on
https://flutter.dev/docs/deployment/android#build-an-apk
https://flutter.dev/docs/deployment/android#build-an-app-bundle
https://developer.android.com/studio/build/configure-apk-splits#configure-split
Run flutter build apk --split-per-abi
This command results in three APK files:
<app dir>/build/app/outputs/apk/release/app-armeabi-v7a-release.apk
<app dir>/build/app/outputs/apk/release/app-arm64-v8a-release.apk
<app dir>/build/app/outputs/apk/release/app-x86_64-release.apk
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.
ABI means : Application Binary Interface
APK means : Android Package
app dir is your application’s directory
NOTE : If you can build an app bundle instead of apk , do it .With this, the application will be signed more easily .
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).
Remember that creating an App Bundle (an .aab file) is preferred over creating a fat APK or multiple APKs per abi. To assemble an App Bundle, run flutter build appbundle. The bundle will be created at build/app/outputs/bundle/release/app.aab
I am trying to build an android app using cordova 8. As soon as cordova build android --release with keystore.
It releases 5 apk file in 5 folder, but I am not sure, which one to upload:-
arm64
armeabi
armv7
x86
x86_64
Now, I am not sure, which one to release and upload for google play after signing.
Are you using a plugin containing native libraries? (I'm still using version 6 of Cordova and have only one apk, so either it's new in earlier versions or it's something to do with your project).
The different APKs you're seeing are to support different processors on the devices.
Most devices use armv7 so that's probably the one you want to upload first, but you can upload all the apks to google play.
It you upload only one (ore some) of the APKs, your app will be compatible only with device using corresponding kind of processor.