Flutter APK size it's greater than 150mb - flutter

i'm having some problems while compiling my flutter app for Android.. I've only 3 assets and a couple packages added, but when I try to compile, I got this:
√ Built build\app\outputs\flutter-apk\app-release.apk (158.3MB).
Any idea?
Flutter build log (running flutter build apk)
PS C:\\Users\\Admin\\Desktop\\Fictix\\Don't Touch This\\app\\dtt_app\> flutter build apk
Building with sound null safety

First of all, you can try clearing the cache via terminal.
flutter clean
This command will delete few temporary folders, specially "build/", ".dart_tools/" and ".packages/".
You can also run the following code from the terminal before the build phase of your application.
flutter build appbundle --target-platform android-arm,android-arm64
Of course, it is not a 100% method, but it can work in reducing your application size.
You can follow the steps below to clear it by Android Studio.
Tools > Flutter > Flutter Clean
Make your app with no sound null safety
From Terminal Run This Command
flutter build apk --split-per-abi --no-sound-null-safety
or
flutter build apk --release --no-sound-null-safety
If your problem still persists
// #2.9 in the top remove the parameter from Const app_name();
Run --no-sound-null-safety from terminal
Edit your Configure File and write in Additional run args:- --no-sound-null-safety

Related

appbundle being generated with the empty String.fromEnvironment

I'm storing some settings in String.fromEnvironment('CONFIG_EX'), when I run the app in Debug or Profile mode everything works normally, but now I launched it on the PlayStore in Open Test and it's returning a 403 error and I realized that the compilation generated the empty variables.
it's more or less like this in my run settings:
--dart-define=CONFIG_EX=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I'm generating my appbundle this way:
flutter build appbundle
Is there any way to generate this appbundle with the run settings?
You can extend build commands with extra parameters.
Android:
flutter build appbundle --dart-define=CONFIG_EX=xxx
iOS:
flutter build ios --dart-define=CONFIG_EX=xxx

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

APK building failed in flutter

I've been trying to build an apk for my app but its failing and I don't understand why
this is what is shwoing
i tried to build using this command that was given to me in comments
flutter build apk --no-tree-shake-icons
but its showing me this new error now
Try add this when build your apk --no-tree-shake-icons
Generally, for errors that seem odd like this, running flutter clean then flutter pub get in the terminal helps.

How to get .apk and .ipa file from flutter?

I am new to flutter programming and I've created a demo app, its running fine on both android and iOS devices. I want to see .apk and .ipa file in flutter. Can anyone help me to get these files from Flutter? Where can I see these files in folders or is there any other solution.
For apk (Android) you need to run the command :
flutter build apk --release
If you want to split the apks per abi (Split Apk) then run
flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
For ipa (iOS) you need to run the command :
flutter build ios --release
From the console
P.S. --release is optional as it is by default
if you need debug build, just replace --release with --debug
you can find the released APK or IPA files form
build/app/outputs/flutter-apk/app-release.apk
For Android an APK is generated every time you build the app, e.g. with flutter run. You will find that in your project folder under <project>/build/app/outputs/apk/debug/app-debug.apk. If you want a release APK, have a look at the docs.
I'm not an iOS person, so I'm not sure an IPA is generated during development as in android. But looking at these docs it seems you can follow the standard steps on xcode to get it, as shown here.
For apk (Android) run the command :
flutter build apk --release
For ipa (iOS) run the command :
flutter build ios --release
Then to get actual .ipa file, open xcode -> Product -> archive -> Distribute App -> Ad Hoc -> Export
You can then save the .ipa(which is inside the Runner folder) file in any location
I also had this question and had a really tough time finding the right solution.
First of all in the terminal of your code editor type:
flutter build apk --release
and after that go to this location:
yourAppFolder/build/app/outputs/apk/release/app-release.apk
I do not do development for iOS so I don't know much about that.
For Android, an APK is generated every time you build the app, e.g. with flutter run. You will find that in your project folder under <project>/build/app/outputs/apk/debug/app-debug.apk.
Follow below steps to get .apk and .ipa from flutter app in Mac system
First, Enter below command in your terminal to go your project directory
cd $(PROJECT FOLDER PATH)
For android apk build to upload store, Enter below command
sudo $(FLUTTER SDK PATH till bin)/flutter build apk --release
To get ios ipa , Enter below command
sudo $(FLUTTER SDK PATH till bin)/flutter build ios --release
To get an apk, it is simple. Just use :
flutter build apk
To get an ipa, It is more complicated. First use :
flutter build ipa
Be careful to use flutter build ipa, not flutter build ios, because the second one builds a ".app" file instead of ".xcarchives" file.
Once you have the ".xcarchives" file, you can open it in XCode and click on "Distribute the app" to export an ipa file on your computer.
For iOS:
Step 1: open terminal and type cd "your flutter sdk path"
Step 2: cd export PATH=/Users/yourname/Downloads/flutter/bin:$PATH
Step 3: cd your project path
Step 4: flutter build ios --release
run step 1 to 4 in terminal.
After that open android studio and go to iOS folder path and open project.pbxproj file with ios module and in xcode you need to choose generic ios device and select archive, it will generate ipa build for you.
Android(After adding release build type run below command which will generate release apk with below version)
flutter build apk --build-name=1.0.1 --build-number=1
iOS
flutter build ios --release
For a detail explanation read the below article.
https://medium.com/#ralphbergmann/versioning-with-flutter-299869e68af4
For apk, you can use flutter build apk --release to get the release version of your apk on either windows/macOS.
For ipa, you have to use flutter build ios --release to get the release version of your apk on macOS.
Note: You can get a ipa on macOS only.
If you want this apk and .ipa with flavour then you can refer below commands for internal and production.
iOS:
flutter build ios --debug --flavor internal
flutter build ios --release --flavor production
android:
flutter build apk --debug --flavor internal
flutter build apk --release --flavor production
Updated for iOS :-
first you need to go to your current working directory and run the following command;
flutter build ios --release
After successfully completion of build, you can find build on below path;
/Users/sanjaybalaji/Documents/KiranFlutterApps/hb_calculator/build/ios/iphoneos/Runn
er.app.
you can check below screenshots for more details.
You can find your app apk after you run the app at path
<project_dir>/build/app/outputs/flutter-apk/app.apk

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