Xamarin + Android + Binding YouTube video player compile errors

后端 未结 2 1036
执笔经年
执笔经年 2021-01-06 03:12

I\'m looking to bind the YouTubeAndroidPlayerApi.jar into my Xamarin Android project. I\'ve added the YouTubeAndroidPlayerApi.jar under my Jars folder, but my project won\'

相关标签:
2条回答
  • You should just be able to remove this fairly easily. However your issue in your <attr> is the fact that you have the incorrect package name/class name as it should follow Java convention(<lowercase package>.<propercase class>). Simply ensure the case like the example below:

    EX:

    <remove-node path="/api/package[@name='com.google.android.youtube.player']/class[@name='YouTubeThumbnailView']/method[@name='finalize' and count(parameter)=0]" />
    
    0 讨论(0)
  • 2021-01-06 04:10

    If you add the remove-node, you will remove the finalizer and the code under finalize method will never be called. If you want to re-use the finalize implementation in the destructor, you can add the following to your Metadata.xml file:

    <!--  
        YouTubeThumbnailView class implemented a Java Finalizer. I have to implement a C# Destructor and call the finalize method.
        The C# Destructor is in the partial class under the Addition folder.
    -->
    <!-- I change the name of the finalizer method to avoid the conflict with java finalizer -->
    <attr path="/api/package[@name='com.google.android.youtube.player']/class[@name='YouTubeThumbnailView']/method[@name='finalize' and count(parameter)=0]" name="managedName">InternalFinalize</attr>
    <!-- I replace the protected override modifier with the internal modifier -->
    <attr path="/api/package[@name='com.google.android.youtube.player']/class[@name='YouTubeThumbnailView']/method[@name='finalize' and count(parameter)=0]" name="visibility">internal</attr>
    

    N.B. the visibility modifier is needed to remove the override modifier.

    Then you should add the following class under the folder Additions:

    namespace Com.Google.Android.Youtube.Player
    {
        public partial class YouTubeThumbnailView
        {
            ~YouTubeThumbnailView()
            {
                this.InternalFinalize();
            }
        }
    }
    
    0 讨论(0)
提交回复
热议问题