EgorBo / Toasts.Forms.Plugin

A plugin for Xamarin and Windows - it unites Crouton (Android), TWMessageBarManager (iOS) and my toast notificator for WP8.
MIT License
278 stars 84 forks source link

System.MissingMethodException: Method 'Android.App.Notification/Builder.SetChannelId' not found. #155

Open jelkevdh opened 6 years ago

jelkevdh commented 6 years ago

Version 3.2.1 works fine, but versions 3.3.0 and higher have the following exception:

-       ex  {System.MissingMethodException: Method 'Android.App.Notification/Builder.SetChannelId' not found.
  at Plugin.Toasts.ToastNotification+<>c__DisplayClass5_0.<Notify>b__0 () [0x00054] in D:\Source\Repos\Toasts.Forms.Plugin\Toasts.Forms.Plugin.Droid\ToastNotification.cs:44 
  at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Threading.Tasks.Task.Execute () [0x00010] in <657aa8fea4454dc898a9e5f379c58734>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at Plugin.Toasts.ToastNotification+<Notify>d__5.MoveNext () [0x00031] in D:\Source\Repos\Toasts.Forms.Plugin\Toasts.Forms.Plugin.Droid\ToastNotification.cs:33 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at LoginViewModel+<NavigateToRegisterPageAsync>d__32.MoveNext () [0x00066] in LoginViewModel.cs:187 } System.MissingMethodException
adamped commented 6 years ago

@jelkevdh - This is not enough information to solve this issue. Please mention which API version you are building and using, and which device this occurs on. Does it occur on all devices/APIs? Please load up the Toasts project source code and try to figure out the error as well. Then you could submit a PR with the actual bug fix. Otherwise this error likely won't be solved, because I can not duplicate it.

Nico04 commented 6 years ago

I have the exact same bug, with a (almost) blank project (.NET Standard), with all component up-to-date, using the simple example in readme of this repo. Works fine with v3.2.1 (after cleaning solution). Android 7.0.

mgoodfellow commented 6 years ago

What is interesting is this commit from Jan 2018:

https://github.com/EgorBo/Toasts.Forms.Plugin/commit/a4662785fe876595482ee46e54eb30f8cd7cb150#diff-eb4edc0732b64df8b7078b5537ddb7f5R223

This actually adds a comment about a runtime version of this exception, but now something else has changed and it won't link anymore. I have been using 3.3.0 since December, and suddenly I can't build anymore as the linker isn't happy. I haven't changed any versions of Android support libraries, so it might even be a change to the Xamarin linker which is now stricter in a later patch version of VS.

mgoodfellow commented 6 years ago

As an aside, I have lifted my minimum supported Android version to 6.0 (API Level 23 - Marshmellow) and it links fine now. I was using Android 5.0 (Level 21) previously.

tidusjar commented 6 years ago

I'm getting the above error and I tried @mgoodfellow suggestion but still no avail on Android. Using latest nuget package

mgoodfellow commented 6 years ago

@tidusjar Some other things I did - I built using Android 8 Oreo SDK, and I also forced the Target Android version to Android 8. I also removed the bin/obj folders by hand rather than cleaning the solution! Also building on latest VS2017 15.6.5 + tools

I'm using Xamarin.Android.Support.v7.AppCompat 25.4.0.2 as well - might have some relevance as that is its dependency?

PostImpatica commented 6 years ago

I dropped down to 3.2.1

cassionandi commented 6 years ago

Same error here. Same version of @mgoodfellow, did his suggestion but did not work. Version 3.2.1 also did not work.

mslavkovski commented 6 years ago

Same error here, are there any solutions?

PostImpatica commented 6 years ago

@cassionandi I would write a dependency service that creates toasts. This is what I've started doing when I run out of options. I did this recently when I found that the xam.plugins.messaging plugin was forcing my xamarin ios project to want to install .netstandard 1.6 and a bunch of other packages.

HERE is a stack overflow showing you how to create toasts using a dependency service in iOS (look at Alex Chengalan's solution). iOS is always the most difficult for me so that is where I start. If I can find an easy solution for iOS it's normally even easier in Android so then I proceed.

cassionandi commented 6 years ago

@helzgate I am using this kind of solution for a while. For iOS the Toast.iOS did the Toast-like Android to me without any effort. Recommended.