Flutter launcher_icon and native_splash android problem - android

I am beginner in flutter, and I started learning from the very beginning of creating the application and immediately encountered a problem that I cannot solve only on android. When i create packages launcher_icon and native_splash, on ios everything works as it should, but on android at the splash screen all the time it gives me only the application icon and not default splash screen as in ios.
how could i fix it to work on android?
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^2.0.0
flutter_launcher_icons: ^0.10.0
flutter_native_splash: ^2.2.7
flutter_icons:
android: true
ios: true
image_path: "assets/icon_anny.png"
min_sdk_android: 21
flutter_native_splash:
color: "#fafafa"
image: assets/splash_screen.png
color_dark: "#000000"
image_dark: assets/splash_screen_dark.png
android: true
ios: true
android_gravity: fill
ios_content_mode: scaleAspectFill

I managed to solve the problem, Android 12 has a different way of showing the splash screen. It is also necessary to open a new one flutter_native_splash.yaml and there are all the instructions and it works perfectly.

You should run a command line after adding parameters to pubspec.yaml:
flutter pub run flutter_native_splash:create

I just fixed this problem today go in your project and create a flutter_native_splash.yaml and follow the instructions on https://pub.dev/packages/flutter_native_splash.

Related

Dart Socket ERROR: ../../third_party/dart/runtime/bin/socket_android.cc:147: `reusePort` not supported for Android

I'm new to flutter development. I'm building a remote app for android and iOS that will let users to control their legacy TV via infrared, and smart tv via WIFI. This exception only appears for android. On iOS app is working fine. I' using the following package to discover devices in my app.
upnp2: ^0.3.2
Here is all the dependencies used in my project.
cupertino_icons: ^1.0.2
rxdart: ^0.27.3
sqflite: ^2.0.2
shared_preferences: ^2.0.12
ir_sensor_plugin: ^0.2.0
introduction_screen: ^2.1.0
network_info_plus: ^2.1.2
ping_discover_network_forked: ^0.0.1
web_socket_channel: ^2.1.0
http: ^0.13.4
upnp2: ^3.0.6
multicast_dns: ^0.3.2
There is no other exception appeared in tracing. I don't know why its happening only for android while its working fine for iOS. Please help me!
the new version of upnp2 (3.0.10) should have fixed this issue, sorry for the late response. Please try out again and let me know the results.

flutter android app freezes on the splash screen in release mode

I have a problem using the storage to persist the user login data .
the scenario like that : after login , I clear the app and try to reopen it again , sometimes it open and sometimes it's freezes on the splash screen.
this only happen in the release mode .
I tried to remove every package until I found the problem with using the storage after login. so I if I not login nothing freezes .
I used get_storage and shared_preferences and secured_storage packages but nothing changed .
flutter 2.10.2.
tested on real device
also this the the used packages
module:
androidX: true # Add this line.
environment:
sdk: ">=2.11.0 <3.0.0"
dependencies:
dio: ^4.0.0
get: ^4.1.4
get_storage:
flutter:
sdk: flutter
dev_dependencies:
flutter_launcher_icons: ^0.9.2
flutter_icons:
android: true
ios: false
image_path: "assets/icons/launcher_icon.png"
flutter_test:
sdk: flutter
name: delivery
description: manager App
version: 1.6.3
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
finally I decided to share the verbose hope someone can help
https://github.com/flutter/flutter/issues/98862
I had the same problem in our production app few days back. I released an update (where just a couple of tables were updated in the local app database) with Flutter 2.10.2 and many users started getting frozen launch screen.
After spending days trying to solve it, I finally downgraded the Flutter to 2.8 and released an update and the issue was gone.
I had a similar bug:
By default on Android, android:allowBackup is set to true which means that your app's data is automatically backed up to your Google Drive
The problem is when something in your data structure changes but you have an old backup with an old and incompatible data structure. When reinstalling a new version of the app which is incompatible with the old data structure which was backed up, it will freeze on the native splash screen.
I solved this by adding android:allowBackup="false" to android/app/src/main/AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
<application
...
android:allowBackup="false"
...
</application>
</manifest>
You could install sentry_flutter in your application to capture exceptions in your release app.
Also, try moving flutter_native_splash: ^2.0.4 from dev_dependencies to dependencies.
Take you real device and connect it to you pc via cable and install release version of you app
Go-to terminal and run flutter logs to see what's going on
In some cases, may be permissions are reason. You need to specify them (don't relax because of default permissions set)
I think there should be 2 things --
first make sure you added the Internet permission and other required permissions in AndroidManifest.xml file
Second if you already defined all the required permissions then try this--
in your app/build.gradle file add these 3 lines
minifyEnabled false
useProguard false
shrinkResources false
in
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
minifyEnabled false
useProguard false
shrinkResources false
}
}
then clean your project and try again I hope this will work and if you still faced that problem check the documentation again of flutter_native_splash package you used, also watch the video of Johannes Milke's tutorial which is already linked in the documentaion.
Thankyou.
Since the other answers haven't given any luck, I would suggest that you start by disabling everything in your app, and gradually enable portions of the app until you reproduce the problem. For example, start by replacing your MyApp() in your main() with a blank shell of an app:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent, // transparent status bar
));
await initServices();
runApp(MaterialApp(
home: Container(color: Colors.blue),
));
}
This will tell you if the problem is in your initialization or the rest of your app. If the blue screen loads, it tells you that the initialization is fine. Keep dividing your app like this until you find the part this is causing the app to hang.
I recommend you to install the flutter sdk again from scratch and try it.

How to change app icon in flutter using VS Code?

How to change the app icon in Flutter using VS Code?
I am trying it again and again but it's not working. I've seen different methods online with no positive outcome.
You can make use of the flutter_launcher_icons: ^0.9.2 package
Create new folder named assets and a subfolder inside that named icon then make changes in your pubspec.yaml file like following:
dev_dependencies:
flutter_launcher_icons: "^0.9.2"
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/icon.png"
Here the icon image should be icon.png and it will be stored in the path : assets/icon
now in terminal run
flutter pub get
for further info check this as reference. And this video might be helpful.
With the help of flutter plugin you may change flutter icon package:
flutter_launcher_icons: ^0.9.2
Step 1:
dev_dependencies:
flutter_launcher_icons: "^0.9.2"
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/icon.png"
Step 2:
flutter pub get
Use current method Flutter Launcher Icons.
Edit pubspec.yaml file:
dev_dependencies:
flutter_launcher_icons: "^0.10.0"
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icon/icon.png"
min_sdk_android: 21 # android min sdk min:16, default 21
web:
generate: true
image_path: "path/to/image.png"
background_color: "#hexcode"
theme_color: "#hexcode"
windows:
generate: true
image_path: "path/to/image.png"
icon_size: 48 # min:48, max:256, default: 48
Go to Terminal:
flutter pub get
flutter pub run flutter_launcher_icons:main
Have a nice day...
Source: [https://pub.dev/packages/flutter_launcher_icons][1]

Why my iOS app's size created with Flutter is 475MB?

I created my first app. Not so big, news app. My dependencies:
provider: ^4.3.2+2
url_launcher: ^5.5.2
share: ^0.6.5+4
shared_preferences: ^0.5.10
flutter_html: ^1.0.2
cached_network_image: ^2.3.3
flutter_spinkit: "^4.1.2"
pull_to_refresh: ^1.6.3
sqflite: ^1.3.2+1
path_provider: ^1.6.24
connectivity: ^2.0.2
yoyo_player:
shimmer: ^1.1.2
firebase_messaging: ^7.0.3
dio_http_cache: ^0.2.11
dio: ^3.0.10
hive: ^1.4.4+1
hive_flutter: ^0.3.1
scrollable_positioned_list: ^0.1.8
I will list app sizes in different cases:
flutter build apk => size around 25MB.
flutter build apk --split-per-abi => size around 10MB.
flutter build ios => size of Runner.app is 475MB (I'm not joking).
Ok I can compress it => size 203MB - This is
Ok, flutter I'll create a blank app
flutter build ios => size of Runner.app is 65MB and after compress 23 (this seems affordable).
I hope this will you
flutter clean
flutter build ios --analyze-size
After I Archived app with XCode and deployed to the App Store app size was only 45MB (shown on Console) and after download to actual device size was only 29 MB.
From 475 to 29MB. That was amazing!
I think this can be helpful to someone else, so don't worry about size...

Android Studio Launcher Icon - Icon Name Must Be Set

I am developing a Flutter app right now and trying to change the Android app's icon to a .png image. On Android Studio, I get this error when I do File -> New -> Image Asset:
Any help with this?
In you pubspec.yaml file add this,
dev_dependencies:
flutter_test:
sdk: flutter
flutter_launcher_icons: "^0.6.1"
flutter_icons:
android: true
ios: "Example-Icon"
image_path: "assets/icon/icon.png"
image_path_android: "assets/icon/icon_android.png"
image_path_ios: "assets/icon/icon_ios.png"
adaptive_icon_background: "#FFFAFAFA"
adaptive_icon_foreground: "assets/icon/icon-foreground.png"
More information can be found here

Categories

Resources