Unable to compile class implementing MediaNotification.IProvider.CreateNotification()
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
Research direction
Start with the generated binding at obj\Debug\net9.0-android\android\src\crc64c44f8a9ee386df14\MediaNotificationProvider.java and compare its createNotification signature with MediaNotification.IProvider.CreateNotification and the AndroidX.Media3.Session.MediaNotification.IProvider documentation. Reproduce the build using a new .NET Android class implementing the interface; done means the generated Java class overrides createNotification and the project compiles.
Written by the indexing model from the issue text.
Description
Android framework version
net9.0-android
Affected platform version
Visual Studio Enterprise 2022 v17.13.1
Description
I am trying to create a class implementing the AndroidX.Media3.Session.MediaNotification.IProvider interface but the IProvider.CreateNotification() function signature doesn't appear to match the Android signature and it won't compile. This is what VS insists is the required declaration of the CreateNotification() function implementation...
public class MediaNotificationProvider : Java.Lang.Object, MediaNotification.IProvider
{
public bool HandleCustomCommand(MediaSession? p0, string? p1, Bundle? p2)
{
return true;
}
MediaNotification? MediaNotification.IProvider.CreateNotification(MediaSession? mediaSession, Java.Lang.Object? mediaButtonPreferences, MediaNotification.IActionFactory? actionFactory, MediaNotification.IProviderCallback? onNotificationChangedCallback)
{
throw new NotImplementedException();
}
}
... but when I try to compile this I get these two error messages...
obj\Debug\net9.0-android\android\src\crc64c44f8a9ee386df14\MediaNotificationProvider.java:4: error: MediaNotificationProvider is not abstract and does not override abstract method createNotification(MediaSession,ImmutableList<CommandButton>,ActionFactory,Callback) in Provider
public class MediaNotificationProvider
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
and
error: MediaNotificationProvider is not abstract and does not override abstract method createNotification(MediaSession,ImmutableList<CommandButton>,ActionFactory,Callback) in Provider
public class MediaNotificationProvider
According to the Android documentation the mediaButtonPreferences argument should be type ImmutableList<CommandButton> but trying the .net version of that doesn't work either and generates the error...
'MediaNotificationProvider.CreateNotification(MediaSession?, ImmutableList<CommandButton>?, MediaNotification.IActionFactory?, MediaNotification.IProviderCallback?)' in explicit interface declaration is not found among members of the interface that can be implemented
I am guessing the binding is not correct but I'm not familiar enough with .net Android bindings to understand what is going on.
Steps to Reproduce
- Right click on existing .net-android project and choose Add->New Item to create a new class
- Change class to inherit from Java.Lang.Object and MediaNotification.IProvider
- Start typing "MediaNotification.IProvider.Create" and then hit tab to accept the suggested code for CreateNotification()
- Attempt to build your code
Did you find any workaround?
No response
Relevant log output
- Dominant language
- C#
- Stars
- 318
- Forks
- 73
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 10
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/android-libraries
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
dotnet/android-libraries#1503 ·
-
dotnet/android-libraries#1470 · 1 reaction · 2 assignees ·
-
dotnet/android-libraries#1467 · 1 reaction · 2 assignees ·
-
Difficulty 5/5 Over a week Newbie friendliness 45/100
dotnet/android-libraries#1456 · 2 comments · 1 reaction ·
-
area-androidx missing-api
Difficulty 4/5 3-5 days Newbie friendliness 52/100
dotnet/android-libraries#1453 ·
All issues in dotnet/android-libraries
Similar issues
-
type/automation type/tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
t/bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ci-failure-cause test-failure
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
area:auth FE mvp P3
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
klasolsson81/jobbliggaren#1788 ·