AndroidNotificationListener icon indicating copy to clipboard operation
AndroidNotificationListener copied to clipboard

flutter run issues

Open answer0732 opened this issue 5 years ago • 8 comments

hi, i am using this plugin for my app, but throw a problem

e: D:\flutter\.pub-cache\hosted\pub.flutter-io.cn\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (73, 28): Type mismatch: inferred type is String? but TypeVariable(V) was expected
e: D:\flutter\.pub-cache\hosted\pub.flutter-io.cn\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (74, 31): Type mismatch: inferred type is String? but TypeVariable(V) was expected
e: D:\flutter\.pub-cache\hosted\pub.flutter-io.cn\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (75, 28): Type mismatch: inferred type is String? but TypeVariable(V) was expected
e: D:\flutter\.pub-cache\hosted\pub.flutter-io.cn\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (76, 29): Type mismatch: inferred type is String? but TypeVariable(V) was expected

this is your code:

  internal inner class NotificationReceiver : BroadcastReceiver() {
    val TAG = "NOTIFICATION_RECEIVER"
    override fun onReceive(context: Context, intent: Intent) {
      val packageName = intent.getStringExtra(NotificationListener.NOTIFICATION_PACKAGE_NAME)
      val packageMessage = intent.getStringExtra(NotificationListener.NOTIFICATION_PACKAGE_MESSAGE)
      val packageText = intent.getStringExtra(NotificationListener.NOTIFICATION_PACKAGE_TEXT)
      val packageExtra = intent.getStringExtra(NotificationListener.NOTIFICATION_PACKAGE_EXTRA)
      val map = HashMap<String, Any>()
      map["packageName"] = packageName
      map["packageMessage"] = packageMessage
      map["packageText"] = packageText
      map["packageExtra"] = packageExtra
      eventSink?.success(map)
    }
  }

how to fix this, thanks !

answer0732 avatar Oct 28 '20 23:10 answer0732

Tell me , did you upgrade to the latest version of Android SDk and flutter ?. I suspect that it has to do with it.

However I am currently working on a project right now so I can't upgrade my environments yet I am sorry....

I will try to check that out though

PavieOlivier avatar Oct 29 '20 02:10 PavieOlivier

yes, all upgrade to the latest version of Android SDk and flutter

answer0732 avatar Oct 29 '20 05:10 answer0732

Yeah I really suspect that it has to do with it . Once I do update everything on my side, I will try working on this package.. However it will take a long time because I am in the middle of an important project so updating now (because of numerous breaking changes) will cause lots of trouble to me....

However if you're on zoom we can have a video call... You fork the project and I will try to help you out

PavieOlivier avatar Oct 29 '20 10:10 PavieOlivier

Sorry, I cannot make a video call with you. network restrictions in my place. I'm not in a hurry to use it. I can wait, You can work on your project first, and good luck to you~!

answer0732 avatar Oct 29 '20 12:10 answer0732

e: E:\development\flutter\.pub-cache\hosted\pub.dartlang.org\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (73, 7): Type inference failed: Cannot infer type parameter V in inline operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit None of the following substitutions receiver: MutableMap<String, Any> arguments: (String,Any) receiver: MutableMap<String, String?> arguments: (String,String?) can be applied to receiver: kotlin.collections.HashMap<String, Any> /* = java.util.HashMap<String, Any> */ arguments: (String,String?)

having similar problem

shinewanna avatar Jan 23 '21 05:01 shinewanna

Facing the same issue here

albertlieyingadrian avatar Mar 09 '21 15:03 albertlieyingadrian

e: E:\development\flutter\.pub-cache\hosted\pub.dartlang.org\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (73, 7): Type inference failed: Cannot infer type parameter V in inline operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit None of the following substitutions receiver: MutableMap<String, Any> arguments: (String,Any) receiver: MutableMap<String, String?> arguments: (String,String?) can be applied to receiver: kotlin.collections.HashMap<String, Any> /* = java.util.HashMap<String, Any> */ arguments: (String,String?)

having similar problem

I have the same problem

OscSer avatar Mar 23 '21 22:03 OscSer

e: E:\development\flutter\.pub-cache\hosted\pub.dartlang.org\android_notification_listener2-2.0.1\android\src\main\kotlin\com\emilecode\android_notification_listener2\AndroidNotificationListener2Plugin.kt: (73, 7): Type inference failed: Cannot infer type parameter V in inline operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit None of the following substitutions receiver: MutableMap<String, Any> arguments: (String,Any) receiver: MutableMap<String, String?> arguments: (String,String?) can be applied to receiver: kotlin.collections.HashMap<String, Any> /* = java.util.HashMap<String, Any> */ arguments: (String,String?) having similar problem

I have the same problem

I fixed this by changing the line from

https://github.com/PavieOlivier/AndroidNotificationListener/blob/8603f48e082c24d32d439e9f866c38339778cb28/android/src/main/kotlin/com/emilecode/android_notification_listener2/AndroidNotificationListener2Plugin.kt#L72

to

val map = mutableMapOf<String, String?>()

Which seems to have worked on Flutter 2.0.3

qcasey avatar Apr 01 '21 19:04 qcasey