'How can I run release build of my Flutter app on Simulator
I need to take screenshots of my Flutter application across various devices. Since I do not have a variety of physical devices, I need to use the Simulator. However, I cannot figure out how to run my app in non-debug mode -- I always see the "Debug" banner in the top right corner. How can I run a Release build in the iOS Simulator?
When I try: flutter run --release
, it says, "Release mode is not supported for emulators."
When I try: flutter install
, it says:
[ +108 ms] An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
[ +12 ms] "flutter install" took 4,601ms.
Install failed
Alternatively, can I run a debug build without showing the Debug banner?
Solution 1:[1]
You won't be able to run release mode on simulator as it only runs on actual device.
However you can remove the debug banner by passing debugShowCheckedModeBanner:false
in your MaterialApp()
MaterialApp(
debugShowCheckedModeBanner:false,
home:...
)
Solution 2:[2]
The command flutter run --release
compiles to release mode.
To remove "debug banner" you can use debugShowCheckedModeBanner property of MaterialApp() widget. If you set this property to false , banner will be disappeared.
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
debugShowCheckedModeBanner: false,
);
}
}
Solution 3:[3]
No, you can't run release build on Emulator. you need a actual device to run release build and ios devices won't support release build.
To run release build on android devices
flutter run --release
To get release build on your storage
flutter build apk --release
This will generate a release build, If you want to get a normal build run below command
flutter run
If you want to get ios build you should run this command ( you can't run this command on Windows and LINUX computers, You need a MAC system for get ios build )
flutter build ios
I hope this will help someone who new to flutter
Solution 4:[4]
The command flutter run --release
compiles to release mode.
check the official doc for Flutter's build modes
Solution 5:[5]
Running flutter run --release
worked for me even on the emulator and also I received FCM notification.
Solution 6:[6]
run
flutter clean
enable
android:debuggable="true"
in manifestflutter build --release
it works for me in emulator pixel 3 and real device
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Shubham Gupta |
Solution 2 | progNewbie |
Solution 3 | Anandh Krishnan |
Solution 4 | yathavan |
Solution 5 | Danish Khan |
Solution 6 | Ahmed Ashour |