How to `flutter run` just for my architecture? - flutter

My flutter app is of course multiarchitecture and uses Rust code.
Curerently, when I do flutter run, it rebuild the Rust library for x86_64 and aarch64, even though I'm running on a phone with just aarch64 (or couse).
Is there a way to build the native binaries only for the phone target?

Hey if you want to split your output build for architecture wise, then you can use flutter build apk --split-per-abi command.

Related

Flutter apk file building taking huge time

I am using Android Studio to run Flutter. I have 8GB RAM, 256GB SSD. But whenever I am going to generate an apk file, it's taking an unlimited time. I have tried all possible command like:
flutter build apk --release
flutter build apk --split-per-abi
flutter build apk --build-name=1.0 --build-number=1
But still, the apk is not generating. It is showing:
Building with sound null safety
`Running Gradle task 'assembleRelease'...` \
What should I do?
I have found something interesting here. After commanding mentioned command, if I do not close the terminal it's building nonstop. But if I close the terminal and let it go doing my other work, it executes very quickly. I do not know why, but it happens several times here for me.
first use this command
flutter clean
and then
flutter build apk --split-per-abi
this command is enough for generating all type apk

How can I build an apk WITH a deprecated plugin on android studio?

My flutter application is using a plugin that has been discontinued. The app runs well in an emulator but android studio gives out the message 'java uses or overrides a deprecated API' when I try to build an apk. I don't want to go through the hassle of finding a different plugin now and change the code everywhere. Is there a way to build the apk on android studio without having to update dependencies?
ps. I'm creating this app purely for coding practice.
i had same problem and these follow steps solved my problem:
flutter clean
flutter pub get
flutter build apk --release --split-per-abi
if there is a deprecated api, it will recompile with -Xlint

how delete architecture in flutter apk

I'm making an app on flutter(i'm a rookie on this language), and i see on the lib folder of the app 6 architectures x86, x86_64, mips, armeabi, armeabi-v7a, arm64_v8a but to upload on the playstore just need 2 armeabi-v7a and arm64_v8a. my question is, how can i compile the app without the other 4 architectures to reduce the size of the app because with the 6 folders it is 140MB?
p/s: English is not my natural lenguaje
Looks like you're only doing flutter build hence, you're getting so many builds.
Here's what you can do,
if you're building for a play store, the recommended way to do is by building an appBundle which you can refer how to here
you can try flutter build apk --split-per-abi which will produce only 3 versions arm64-v8a, armeabi-v7a and x86 so you can extract the two and upload.
Additionally, you can build for only specific platforms by using this command
flutter build apk --target-platform android-arm64,android-arm --split-per-abi
refer this for more information on splitting.
in ../android/app/build.gradle add the lines
android {
...
defaultConfig {
...
ndk {
abiFilters "armeabi-v7a", "arm64-v8a"
}
}
}
built for all architectures by default

Flutter crash on release apk installed on devices / Emulator

Could you guys please help me with the problems I currently have?
I'm trying to follow the steps of how to release apk android from: https://flutter.dev/docs/deployment/android, The program which I tried to release is only the NewFlutterApplication which created from template of Flutter
The problem is: Have been followed all the steps, still I can't run the release apk which i build from flutter
The Error which I got:
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install E:\FlutterProject\flutter_app_1\build\app\outputs\apk\app.apk: Failure [INSTALL_FAILED_NO_MATCHING_ABIS: Failed to extract native libraries, res=-113]
Install failed
The things that I have tried:
Tried from this site Flutter release apk is not installing on device, but there is no hope
Tried from this site Can't build release APK for flutter, but still no hope
Tried using the flutter run --release in the real device, it's directly crash and return stopped working
Tried using the flutter build apk && flutter install, it's not running and give the error from top error
Tried using flutter run -v it don't give any error and run smoothly and the debug it's still run smoothly, only the release APK is the problem which can't be run
UPD: This answer is outdated, Flutter now supports x86/x64
You can't run release build on emulator, because currently flutter doesn't support x86 release binaries
See this issue, and put thumb up reaction on it to increase priority:
https://github.com/flutter/flutter/issues/9253
This issue also affects devices that use Intel Atom and some Chromebooks, but don't worry, they will be excluded from supported devices by Google Play automatically
INSTALL_FAILED_NO_MATCHING_ABIS is when you are trying to install an app that has native libraries and it doesn't have a native library for your cpu architecture. For example if you compiled an app for armv7 and are trying to install it on an emulator that uses the Intel architecture instead it will not work.

how to build apk create old version app in Flutter

I am trying to build my release app in Flutter and when I run:
flutter run
everything works fine in debugging and test mode. But when I was trying to build a release app with:
flutter build apk
it creates an old first-release app of mine. That I created before and I try to reset the computer reset android and everything but not work what can I do to reset it and clear the cache?
I'm trying almost to delete and reset everything but they don't work.
What command that I have to run to fix it and create new version release apk
The solution is easy.
Just run flutter clean and run flutter build apk after that and it generates the updated app apk.
If you want to install it directly just run flutter install after the build command.
To all the beginners If you wish to release an apk of a flutter app just do:
flutter run --release
(and make sure to connect your device to a phone)
steps to ensure your phone is connected:
1. enable usb debugging mode in your phone
2.click on version number of your phone in system settings to enter into developer mode
3. change the phone mode to transferring file mode
After you run the command
go to build->apps->output->apk
run these command
flutter clean
and after that
flutter build apk --release
Run this command for making a bundle.
flutter build appbundle --target-platform android-arm,android-arm64,android-x64
If flutter clean and flutter build apk also generates apk with old version code in your pubspec.yaml change the version like this version: 1.0.2+2
Before + it is your version name and after + sign it is your version code
NOTE: Your new version number should be in the place of 2. Or you can use different format such as 1.2+2
You can run flutter clean Then run flutter build apk --split-per-abi to split the apk. It will build three apks and you can find them in build/app/outputs/flutter-apk/
Can be done easily by Android Studio