Dagger2 @Nullable注释与Kotlin

从匕首模块:

@Provides @PerMediaSession @Nullable MediaControllerCompat provideMediaController(Context appContext, MediaSessionCompat mediaSessionCompat) { try { return new MediaControllerCompat(appContext, mediaSessionCompat.getSessionToken()); } catch (RemoteException e) { e.printStackTrace(); return null; } } 

我注入的地方

 class PlayerPresenter @Inject constructor(val fileManager: FileManager, @Nullable val mediaController: MediaControllerCompat?) : PlayerContract.Presenter { <...> 

我得到以下编译错误

 Error:(15, 10) error: android.support.v4.media.session.MediaControllerCompat is not nullable, but is being provided by @Provides @...di.PerMediaSession @android.support.annotation.Nullable android.support.v4.media.session.MediaControllerCompat ...di.MediaSessionModule.provideMediaController$app_debug(android.content.Context, android.support.v4.media.session.MediaSessionCompat) at: <...where it is injected...> 

我试图将Dagger模块转换为Kotlin,它的情况下Dagger看到Jetbrains @Nullable注释,但由于某种原因,在构造函数类中看不到注释。

我使用匕首2.9

Kotlin的可操作性非常好,这是我的注意力不集中。

发生这个问题是因为我在Dagger模块中提供了接口实例,并且提供了接收会话compat作为参数的方法,没有Nullable注解。 Dagger确实了解Kotlin中的可空类型,没有任何注释。