Skip to content
This repository was archived by the owner on Aug 27, 2026. It is now read-only.
This repository was archived by the owner on Aug 27, 2026. It is now read-only.

Java bindings incorrectly assigning method as obsolete #1142

Closed

Description

@Archit-Pikle

Android application type

.NET Android (net7.0-android, etc.)

Affected platform version

VS 17.8.0 Preview 1.0

Description

Java bindings are tagging a method as Obsolete even though the api.xml sets it as not deprecated

Our Java bindings are failing with the following error -
Error CS0809 Obsolete member 'MAMIntentService.OnBind(Intent?)' overrides non-obsolete member 'Service.OnBind(Intent?)'

I see the api.xml is correctly tagging the method as not deprecated -

<method abstract="false" deprecated="not deprecated" final="true" name="onBind" jni-signature="(Landroid/content/Intent;)Landroid/os/IBinder;" bridge="false" native="false" return="android.os.IBinder" jni-return="Landroid/os/IBinder;" static="false" synchronized="false" synthetic="false" visibility="public">
        <parameter name="intent" type="android.content.Intent" jni-type="Landroid/content/Intent;" />
      </method>

The generated MAMIntentService.cs file is tagging the method as obsolete -

[global::System.Obsolete (@"deprecated")]
[Register ("onBind", "(Landroid/content/Intent;)Landroid/os/IBinder;", "")]
public override sealed unsafe global::Android.OS.IBinder? OnBind (global::Android.Content.Intent? intent)

This is only happening on .NET 8 and started occurring with the latest release.

Steps to Reproduce

N/A

Did you find any workaround?

No response

Relevant log output

No response

Activity

  1. jonathanpeppers commented on Sep 1, 2023

    @jonathanpeppers
    Member
  2. jpobst commented on Sep 1, 2023

    @jpobst
    Contributor

    My guess would be something to do with #1130.

    Can you provide the full api.xml?

    Also note that it is simply a warning, and you are likely using some form of "warnings as errors" feature to turn it into an error.

  3. transferred this issue fromdotnet/androidon Sep 1, 2023
  4. added
    bugComponent does not function as intended
    generatorIssues binding a Java library (generator, class-parse, etc.)
    on Sep 1, 2023
  5. changed the title [-][.NET 8] Java bindings incorrectly assigning method as obsolete on .NET 8 version Android 34.0.0-preview.7.382[/-] [+]Java bindings incorrectly assigning method as obsolete[/+] on Sep 1, 2023
  6. Archit-Pikle commented on Sep 1, 2023

    @Archit-Pikle
    Author

    Here's the zip containing the api.xml
    api.zip

    Thanks for the note. We are treating warnings as errors in our project

  7. jpobst commented on Sep 1, 2023

    @jpobst
    Contributor

    It looks like MAMIntentService inherits from Android.App.IntentService:

    <class abstract="true" deprecated="not deprecated" extends="android.app.IntentService" extends-generic-aware="android.app.IntentService" jni-extends="Landroid/app/IntentService;" final="false" name="MAMIntentService" static="false" visibility="public" jni-signature="Lcom/microsoft/intune/mam/client/app/MAMIntentService;">
      <method abstract="false" deprecated="not deprecated" final="true" name="onBind" jni-signature="(Landroid/content/Intent;)Landroid/os/IBinder;" bridge="false" native="false" return="android.os.IBinder" jni-return="Landroid/os/IBinder;" static="false" synchronized="false" synthetic="false" visibility="public">
        <parameter name="intent" type="android.content.Intent" jni-type="Landroid/content/Intent;" />
      </method>
      ...
    </class>

    And Android.App.IntentService and its OnBind are indeed [Obsolete]:

    The interesting thing is that according to your error message, MAMIntentService is inheriting Android.App.Service instead:

    Obsolete member 'MAMIntentService.OnBind(Intent?)' overrides non-obsolete member 'Service.OnBind(Intent?)' 
    

    Are you doing something custom that remaps the base class of MAMIntentService?

  8. Archit-Pikle commented on Sep 1, 2023

    @Archit-Pikle
    Author

    The java class Android.App.IntentService does extend Android.App.Service and it's onBind doesn't seem to be deprecated
    https://developer.android.com/reference/android/app/IntentService

    https://developer.android.com/reference/android/app/Service#onBind(android.content.Intent)

  9. jpobst commented on Sep 5, 2023

    @jpobst
    Contributor

    The java class Android.App.IntentService does extend Android.App.Service and it's onBind doesn't seem to be deprecated

    Agreed, but the issue is MAMIntentService extends IntentService which is deprecated, not Service.

    Why does the Java MAMIntentService extend IntentService but the C# MAMIntentService extends Service?

    (Note that this feature (like all of generator) works solely on the Java API side. It does not build a C# model so it does not take any C# base classes into account.)

    It feels like this feature is working as intended, however there are scenarios where the feature is undesired, and we need to provide a way to opt out of it.

  10. locked and limited conversation to collaborators on Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugComponent does not function as intendedgeneratorIssues binding a Java library (generator, class-parse, etc.)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions