How to change app icon in flutter using VS Code? - android

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]

Related

Flutter launcher_icon and native_splash android problem

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.

androidx.room.RoomOpenHelper.e (RoomOpenHelper.java:15)

I'm getting this error in Crashlytics (Firebase). The app is built in Flutter and I'm not sure about this error that I don't get locally:
Fatal Exception: java.lang.IllegalAccessError
Illegal class access: 'androidx.room.v' attempting to access 'androidx.work.impl.v' (declaration of 'androidx.room.v' appears in base.apk)
androidx.room.RoomOpenHelper.e (RoomOpenHelper.java:15)
androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onUpgrade (FrameworkSQLiteOpenHelper.java:2)
android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:489)
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:387)
androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase (FrameworkSQLiteOpenHelper.java:4)
androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase (FrameworkSQLiteOpenHelper.java:4)
androidx.room.RoomDatabase.inTransaction (RoomDatabase.java:2)
androidx.room.RoomDatabase.assertNotSuspendingTransaction (RoomDatabase.java)
androidx.work.impl.model.SystemIdInfoDao_Impl.getWorkSpecIds (SystemIdInfoDao_Impl.java:9)
androidx.work.impl.background.systemjob.SystemJobScheduler.reconcileJobs (SystemJobScheduler.java:20)
androidx.work.impl.utils.ForceStopRunnable.cleanUp (ForceStopRunnable.java:1)
androidx.work.impl.utils.ForceStopRunnable.run (ForceStopRunnable.java:31)
androidx.work.impl.utils.SerialExecutor$Task.run (SerialExecutor.java:2)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
java.lang.Thread.run (Thread.java:923)
apparently, plenty of devices are getting this issue everyday in Android 11 and it happens when the user logs in (I know that because of Crashlytics)
My list of packages and their versions:
l
ine_icons: ^2.0.1
dapackages: ^1.6.0 # keeps packages updated: flutter pub pub run dapackages:dapackages.dart ./pubspec.yaml
flutter_cupertino_localizations: ^1.0.1
flutter_google_places: ^0.3.0
maps_launcher: ^2.0.1 # REMOVED, USE OTHER INSTEAD
uuid: ^3.0.5 # IDs for events
cloudinary_public: ^0.11.0
showcaseview: ^1.1.4 # help for new users
provider: ^6.0.1
cloud_firestore: ^3.1.5
firebase_core: ^1.10.6 # needs Runner/GoogleService-Info.plist
firebase_auth: ^3.3.4 # needs Runner/GoogleService-Info.plist
firebase_analytics: ^9.0.4 # needs Runner/GoogleService-Info.plist
# firebase_crashlytics: ^2.4.3 # needs Runner/GoogleService-Info.plist and NSAppTransportSecurity in Info.plist
http: ^0.13.4
badges: ^2.0.2
flutter_translate: ^3.0.1
flutter_facebook_auth: ^4.1.2
google_sign_in: ^5.2.1 # needs Info.plist modification
sign_in_with_apple: ^3.3.0 # needs Xcode modification https://pub.dev/packages/sign_in_with_apple
shared_preferences: ^2.0.10
share_plus: ^3.0.4
intl: ^0.17.0 # locales for table_calendar and datetime manipulation
jiffy: ^4.1.0 # date manipulation
permission_handler: ^8.3.0 # needs Info.plist modification
csv: ^5.0.1
path_provider: ^2.0.8
package_info_plus: ^1.3.0
after_init: ^0.1.2 # NO NULL
flutter_email_sender: ^5.0.2
flutter_launcher_icons: ^0.9.2
# NEEDS TO BE UPDATED
file_picker: ^4.2.7 # for multiple images selection
image_picker: ^0.8.4+4 # for camera
image: ^3.1.0
url_launcher: ^6.0.17 # needs Info.plist modification
transparent_image: ^2.0.0
cached_network_image: ^3.2.0
carousel_slider: ^4.0.0
flutter_slidable: 1.0.0-dev.9
flutter_svg: ^1.0.0
table_calendar: ^3.0.3
add_2_calendar: ^2.1.2 # Info.plist modification
# NEEDS TO BE UPDATED
in_app_purchase: ^3.0.2 # official one.
device_info_plus: ^3.1.1
flutter_platform_widgets: ^1.12.0
flutter_native_splash: ^1.3.2
intl_phone_number_input: ^0.7.0+2 # NO NULL
country_pickers: ^2.0.0
currency_picker: ^2.0.7
# country_currency_pickers: ^1.0.1 # NO NULL
reorderables: ^0.4.2 # NO NULL reorder rent fields
drag_and_drop_gridview: ^1.0.8 # NO NULL
pdf: ^3.6.5
printing: ^5.6.6 # necessary for the above one
open_file: ^3.2.1 # necessary for the above one
# flutter_statusbarcolor_ns: ^0.4.0 # DO NOT CHANGE
fimber: ^0.6.4
fluttercontactpicker: ^4.6.0
contacts_service: ^0.6.3 # get contacts. Info.plist modification
stack_appodeal_flutter: 1.1.0
For me, I'm suspected about one package that uses sqlite, cached_network_image-> flutter_cache_manager->sqflite, because I have this too. If I'm wrong, it must be android play store related problem because user catches this crash just after update, even before dart main function, in which I cleaned all app directories and cache data by code, and it wasn't usefull.
Yes most of users can use app after clean app data or reinstall app! But it's bad experience for user.
I have opened issue about it in github flutter repo: https://github.com/flutter/flutter/issues/100821
And found some interesting closed similar issue, in which author of issue answered has found problem, I have thought he can help us and asked for some help, right now no answer: https://github.com/adjust/flutter_sdk/issues/73
For caching image I think it's better to use some kind of nosql db but I have not found any package for image cache with nosql db yet. In the future it will be great to this kind of package.
I think I have found solution for this problem, I was getting same type crashes in plenty amount of devices everyday. For me it is about java version and gradle version. First I have tired to update gradle version to latest but java version was not enough to support latest version of gradle, and I was using default android studio java before, I think it was 1.8 version maybe and I installed latest version of java. And configured project to compile with new version of java. After that I rolled out several tests in play console. Till today app doesn't have mentioned crash.

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...

flutter: got error when I add http dependency

I'm studying flutter networking in flutter docs. I totally follow the guidance but when I add http dependency then click Packages get then I get an error. What's wrong? Thanks for any advice.
dependencies:
flutter:
sdk: flutter
qrscan: ^0.2.17
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
http: ^0.12.2 // http dependency I added
the error info is below
Running "flutter pub get" in myProject...
Unexpected character (at character 1)
<html>
^
dart:convert jsonDecode
package:pub/src/source/hosted.dart 190:17 BoundHostedSource._fetchVersions
===== asynchronous gap ===========================
dart:async _CustomZone.runUnary
package:pub/src/rate_limited_scheduler.dart 82:30 RateLimitedScheduler._processNextTask.runJob
package:pub/src/rate_limited_scheduler.dart 85:30 RateLimitedScheduler._processNextTask
dart:async new Future.sync
package:pool/pool.dart 126:18 Pool.withResource.<fn>
This is an unexpected error. Please run
pub --trace '--verbosity=warning' get --no-precompile
and include the logs in an issue on https://github.com/dart-lang/pub/issues/new
pub get failed (65; and include the logs in an issue on https://github.com/dart-lang/pub/issues/new)
Process finished with exit code 65
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
http: ^0.12.2 // http dependency I added
qrscan: ^0.2.17
please write code in this sequence

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