Java 绑定:命名空间“...”中不存在类型“...”。你缺集会吗?

Java Binding: The type `...' does not exist in the namespace `...'. Are you missing an assembly?

我正在尝试创建 Xamarin Java 绑定到 Spotify Android SDK。 SDK 现在分为两部分,一部分用于身份验证,一部分用于播放器。前 java 绑定有效,但是,秒数给我一个错误。

最初的问题是在 Xamarin Forums 上提出的。


嗨,

我正在尝试为 Spotify Android SDK 创建绑定项目。

SDK 分为两个.aar 文件。一种用于身份验证,另一种用于媒体播放(播放器)。 首先,我尝试将两个 .aar 文件都放在一个绑定项目中,但 Player.aar 被忽略了。但是,将其移动到自己的位置似乎可行。

现在,我的问题与生成到 IPlayerNotificationCallback 的 Java 界面 NativePlayerNotificationCallback 有关(因此缺少 og 通知),但在播放器 class 中它试图实现:global::Com.Spotify.Android.Player.INativePlayerNotificationCallback.

我在反编译文件中找不到其他提及 INativePlayerNotificationCallback 的地方。只有 IPlayerNotificationCallback.

我明白这有点难以想象。这是在 JD-GUI 中看到的 java class 文件:

此处列出了生成的文件:

文件内Com.Spotify.Sdk.Android.Player.IPlayerNotificationCallback.cs:

以及错误消息本身

Error CS0234: The type or namespace name INativePlayerNotificationCallback' does not exist in the namespaceCom.Spotify.Sdk.Android.Player'. Are you missing an assembly reference?

对于如何使它起作用的任何见解,我将不胜感激。貌似接口的命名有些不一致,但我不确定。

感谢您的帮助, 弗雷德里克

应该通过向播放器绑定项目添加元数据来解决:

<metadata>
  <attr path="/api/package[@name='com.spotify.sdk.android.player']/interface[@name='NativePlayerNotificationCallback']" name="visibility">public</attr>
</metadata>

和 Player class 扩展(进入 Additions 目录):

using System.Collections;
using Java.Lang;
using Java.Util.Concurrent;

namespace Com.Spotify.Sdk.Android.Player
{
    public partial class Player
    {
        public IList InvokeAll(ICollection tasks)
        {
            return null;
        }

        public IList InvokeAll(ICollection tasks, long timeout, TimeUnit unit)
        {
            return null;
        }

        public Object InvokeAny(ICollection tasks)
        {
            return null;
        }

        public Object InvokeAny(ICollection tasks, long timeout, TimeUnit unit)
        {
            return null;
        }
    }
}

您可能需要通过调用泛型方法来正确实现这些方法。 此外,我还必须将元数据添加到 Auth 库绑定项目(我在您的旧主题中找到了它)并从 Player 项目中引用了 Auth 项目,因为它使用了一些 classes(也许没有必要)。