本文介绍了Java 绑定:名称空间“..."中不存在类型“...".你错过了一个程序集吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to create a Xamarin Java Binding to the Spotify Android SDK. The SDK is now separated into two parts, one for authentication and one for the player. The former java binding works, however, the seconds gives me an error.

最初的问题是在 Xamarin 论坛.

我正在尝试为 Spotify Android SDK.

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

The SDK is seperated into two .aar files. One for authentication and one for media playback (Player).Firstly I tried having both .aar files in one Binding Project, but the Player.aar was ignored. However, moving it to its own seem to work.

现在,我的问题与生成到 IPlayerNotificationCallback 的 Java 接口 NativePlayerNotificationCallback 有关(因此缺少 og Notification),但在 Player 类中它试图实现: global::Com.Spotify.Android.Player.INativePlayerNotificationCallback.

Now, my issue is related to the Java Interface NativePlayerNotificationCallback which is generated to IPlayerNotificationCallback (hence the lack og Notification), but in the Player class it tried to implement: global::Com.Spotify.Android.Player.INativePlayerNotificationCallback.

我在反编译文件中找不到关于 INativePlayerNotificationCallback 的其他内容.只有 IPlayerNotificationCallback.

I can find no other mention of INativePlayerNotificationCallback in the decompiled files. Only IPlayerNotificationCallback.

我知道这有点难以想象.以下是JD-GUI中看到的java类文件:

I understand that this is a bit difficult to imagine. Here are the java class files seen in JD-GUI:

生成的文件列在此处:

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

和错误信息本身

错误 CS0234:namespaceCom.Spotify.Sdk.Android.Player' 中不存在类型或命名空间名称 INativePlayerNotificationCallback'.您是否缺少程序集参考?

我真的很感激任何有关如何使其工作的见解.在我看来,界面的命名有些不一致,但我不确定.

I would really appreciate any insight as to how I can get this to work. It looks to me like there are some inconsistencies in the naming of the interface, but I am not sure.

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

Thank you for helping out,Fredrik

推荐答案

应该通过向 Player 绑定项目添加元数据来修复:

Should be fixed by adding metadata to Player binding project:

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

和播放器类扩展(进入Additions目录):

and Player class extension (into the Additions directory):

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 项目,因为它使用了一些类(也许没有必要).

You will probably need to implement these methods correctly by calling generic methods.Also I had to add metadata to Auth library binding project (I found it in your old topics) and referenced Auth project from Player project as it uses some of the classes (maybe that's no necessary).

这篇关于Java 绑定:名称空间“..."中不存在类型“...".你错过了一个程序集吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 06:10