Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter_local_notifications: "PlatformException (PlatformException(INVALID_ICON, The resource could not be found))

Tags:

flutter

I'm trying to add notifications to my app using the flutter_local_notifications plugin but AndroidInitializationSettings requires a drawable resource and throws this error when one is not provided:

    "PlatformException (PlatformException(INVALID_ICON, The resource  could not be found. Please make sure it has been added as a drawable resource to your Android head project., null))" 

The problem is that I don't know where Android head project is located.

like image 420
And Grow Avatar asked Apr 23 '19 22:04

And Grow


People also ask

What is Flutter_local_notifications?

A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform.

How do I add local notifications to Flutter?

Setting up the Notification Service Open the file and import the following at the top: import 'package:flutter_local_notifications/flutter_local_notifications. dart'; import 'package:timezone/timezone. dart' as tz; import 'package:timezone/data/latest.

How do I display images in Flutter local notification?

To achieve an image on local notification, first add the awesome_notifications Flutter package by adding the following lines in pubspec. yaml file. awesome_notifications is the best flutter package we got to show local notifications in the Flutter app.


2 Answers

Hope you have solved it with above answered method, but I have solved with another method by using existing app icon.

var initializationSettingsAndroid =     new AndroidInitializationSettings('@mipmap/ic_launcher'); 
like image 130
Ankit Katiyar Avatar answered Sep 22 '22 11:09

Ankit Katiyar


Add your icon to [projectFolder]/android/app/src/main/res/drawable (for example app_icon.png) and use that name here:

var initializationSettingsAndroid =     new AndroidInitializationSettings('app_icon'); 
like image 26
Richard Heap Avatar answered Sep 21 '22 11:09

Richard Heap