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.

XML syntax warnings when using JavaSourceJar #850

Description

@cncb-gh

Error Message or Issue

After upgrading to VS 16.10 (from 16.4), I get several general XML syntax errors when trying to compile the https://github.com/Baseflow/ExoPlayerXamarin binding library:

Severity Code Description Project File Line Suppression State Error (1 24): Syntax error, expected: #PCDATA, <tt>, <TT>, <i>, <I>, {@code, {@docRoot}, {@inheritDoc}, {@link, {@linkplain, {@literal, {@value}, {@value, UnknownHtmlElementStart, <p>, <P>, <pre>, <PRE>, @author, @apiSince, @deprecated, @deprecatedSince, @exception, @param, @return, @see, @serialData, @serialField, @since, @throws, @[unknown], @version ExoPlayer.Common C:\Craigs Files\Apps\ExoPlayerXamarin-develop\ExoPlayer.Common\BINDINGSGENERATOR 1

Version Information

Details

Other Helpful Info

Activity

  1. transferred this issue fromdotnet/androidon Jun 14, 2021
  2. removed their assignment
    on Jun 14, 2021
  3. jpobst commented on Jun 14, 2021

    @jpobst
    Contributor

    I think the only current workaround for this is to remove the <JavaSourceJar> files from your .csproj files.

    <JavaSourceJar Include="JavaDocs\*.jar" />
    
  4. added
    bugComponent does not function as intended
    generatorIssues binding a Java library (generator, class-parse, etc.)
    on Jun 14, 2021
  5. jonpryor commented on Jun 14, 2021

    @jonpryor
    Contributor

    @cncb-gh: How are you observing this error? It looks like you have $(TreatWarningsAsErrors) disabled:

    https://github.com/Baseflow/ExoPlayerXamarin/blob/5214b7158fc6611f602ffc0f0122429a3ae49b6d/Directory.Build.props#L22

    We should only be emitting a warning for this, and probably not even a warning… (We should fix that.)

  6. cncb-gh commented on Jun 14, 2021

    @cncb-gh
    Author

    I don' t know - they are showing up as errors in the Build Output as well as the Error List. Is there another setting in VS that might affect this?

    I tried removing the source jar files and now get invalid token errors in some generated files. It is placing '?' in some methods like so (notice "void?"):

    [Register ("writeToParcel", "(Landroid/os/Parcel;I)V", "GetWriteToParcel_Landroid_os_Parcel_IHandler")] public abstract void? WriteToParcel (global::Android.OS.Parcel? dest, [global::Android.Runtime.GeneratedEnum] global::Android.OS.ParcelableWriteFlags flags);

  7. jpobst commented on Jun 15, 2021

    @jpobst
    Contributor

    Looks like this is the full output message that is being emitted:

    ## Unable to translate remarks for com/google/android/exoplayer2/Player:
    
    A media player interface defining traditional high-level functionality, such as the ability to
    
    play, pause, seek and query properties of the currently playing media.
    
    <p>
    
    Some important properties of media players that implement this interface are:
    
    <ul>
    
        <li>They can provide a {@link Timeline} representing the structure of the media being played,
    
        which can be obtained by calling {@link #getCurrentTimeline()}.</li>
    
        <li>They can provide a {@link TrackGroupArray} defining the currently available tracks,
    
        which can be obtained by calling {@link #getCurrentTrackGroups()}.</li>
    
        <li>They contain a number of renderers, each of which is able to render tracks of a single
    
        type (e.g. audio, video or text). The number of renderers and their respective track types
    
        can be obtained by calling {@link #getRendererCount()} and {@link #getRendererType(int)}.
    
        </li>
    
        <li>They can provide a {@link TrackSelectionArray} defining which of the currently available
    
        tracks are selected to be rendered by each renderer. This can be obtained by calling
    
        {@link #getCurrentTrackSelections()}}.</li>
    
    </ul>
    
    Error (31:41): Syntax error, expected: #PCDATA, <tt>, <TT>, <i>, <I>, {@code, {@docRoot}, {@inheritDoc}, {@link, {@linkplain, {@literal, {@value}, {@value, UnknownHtmlElementStart, </tt>, </TT>, </i>, </I>, </p>, </P>, <p>, <P>, <pre>, <PRE>, @author, @apiSince, @deprecated, @deprecatedSince, @exception, @param, @return, @see, @serialData, @serialField, @since, @throws, @[unknown], @version
        {@link #getCurrentTrackSelections()}}.</li>
                                            ^
    

    This part:

    Error (31:41): Syntax error, expected: ......
    

    Is close enough to the MSBuild error format that MSBuild seems to be recognizing it as an actual error, which is not intended.

    image

    I think if we change this line to something else we can get this back to an informational message as intended:

    // JavadocInfo.cs: 189
    writer.WriteLine ($"{m.Level} {m.Location}: {m.Message}");
    
  8. jpobst commented on Jun 15, 2021

    @jpobst
    Contributor

    I have a PR that fixes MSBuild interpreting these error messages as real errors:
    #851

    I believe @pjcollins will be looking at improving the Javadoc parsing in the future to prevent the messages from happening in the first place.

    (See also https://github.com/xamarin/java.interop/issues/843)

  9. cncb-gh commented on Jun 15, 2021

    @cncb-gh
    Author

    Thanks. In the meantime, do you know how I can fix the "invalid token" error when removing the JavaDoc references?

  10. jpobst commented on Jun 15, 2021

    @jpobst
    Contributor

    Did you remove them from all of your projects? I had tried removing them from all the projects, and did not get the invalid token errors you mentioned.

  11. 4 remaining items

  12. cncb-gh commented on Jun 23, 2021

    @cncb-gh
    Author

    Unfortunately, this didn't work for me either. The only thing that works is removing the whole Metadata class with remove-node. Thanks for your help.

  13. cncb-gh commented on Jun 24, 2021

    @cncb-gh
    Author

    Somehow even though it builds successfully, several interfaces and classes are missing in the output. I think I tracked it down to the "Player" interface never being generated. I get this warning but it does not tell me anything specific:

    1>obj\Release\monoandroid10.0\api.xml(3, 6) : warning BG8C01: For type 'Com.Google.Android.Exoplayer2.BasePlayer', base interface 'com.google.android.exoplayer2.Player' is invalid.

    Player Interface:
    https://github.com/google/ExoPlayer/blob/release-v2/library/common/src/main/java/com/google/android/exoplayer2/Player.java

    BasePlayer:
    https://github.com/google/ExoPlayer/blob/release-v2/library/common/src/main/java/com/google/android/exoplayer2/BasePlayer.java

    I would appreciate any more help you are able to give. Thanks for your time.

  14. jpobst commented on Jun 24, 2021

    @jpobst
    Contributor

    That's not one I see very often. It means it found the interface com.google.android.exoplayer2.Player, but there is some issue with it that will prevent it from getting generated.

    Hopefully there is another message somewhere in the diagnostic output that tells what is wrong with the com.google.android.exoplayer2.Player interface.

  15. cncb-gh commented on Jun 24, 2021

    @cncb-gh
    Author

    I turned on "Diagnostic" build output and unfortunately don't see anything that tells what is wrong with the interface. Just the one warning for BasePlayer about the invalid interface and several invalid parameter and return type warnings where the Player interface is attempted to be used. Here is the build output:
    Output-Build.txt

  16. jpobst commented on Jun 24, 2021

    @jpobst
    Contributor

    It's in your log:

    1>        C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Xamarin\Android\Xamarin.Android.Bindings.Core.targets(53,5): message BG0000: obj\Release\monoandroid10.0\api.xml(2220, 10): warning BG8801: Invalid parameter type 'com.google.android.exoplayer2.Player.Listener' for member 'Com.Google.Android.Exoplayer2.IPlayer.RemoveListener (Com.Google.Android.Exoplayer2.IPlayerListener)'.
    1>        obj\Release\monoandroid10.0\api.xml(2030, 6) : warning BG8503: Invalidating 'Com.Google.Android.Exoplayer2.IPlayer' and all its nested types because some of its methods were invalid.
    

    You will need to follow the trail to figure out the root issue causing the types to be invalidated.

    That is:

    • IPlayer is invalidated because IPlayerListener is invalid
    • Search for why IPlayerListener is invalid
    • Repeat as needed
  17. cncb-gh commented on Jun 24, 2021

    @cncb-gh
    Author

    I traced it back to me removing the Metadata class to avoid the 'void?' token error. I have tried both your suggestion as well as

    <attr name="return-not-null" path="/api/package[@name='com.google.android.exoplayer2.metadata']/interface[@name='Metadata.Entry']/method[@name='writeToParcel' and count(parameter)=2 and parameter[1][@type='android.os.Parcel'] and parameter[2][@type='int']]">true</attr>

    but it always generates a 'void?' (it seems that IEntryInvoker is automatically generated by the binder for IEntry because it is not defined in Java). Any other ideas on how to solve this?

  18. jpobst commented on Jun 25, 2021

    @jpobst
    Contributor

    The easiest way to solve it would be to turn off <Nullable> for that assembly.

  19. cncb-gh commented on Jun 30, 2021

    @cncb-gh
    Author

    <Nullable> worked but that uncovered a number of other errors including several runtime Java.Lang.AbstractMethodError exceptions. These seem to mostly have come from a deprecated interface? I'm sure there is a better way to do it, but I had to slowly remove these methods one-at-a-time until the errors stopped. But, I finally have something running successfully so thank you!

  20. changed the title [-]Several XML syntax errors when trying to bind in VS 16.10[/-] [+]XML syntax warnings when using JavaSourceJar[/+] on Oct 21, 2021
  21. added
    javadocIssues with consuming Java documentation formats
    and removed
    generatorIssues binding a Java library (generator, class-parse, etc.)
    on Jul 19, 2022
  22. 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

Labels

bugComponent does not function as intendedjavadocIssues with consuming Java documentation formats

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions