我正在實施匕首2在我的項目中。對於這一點,我已經寫了下面的代碼行:Dagger 2錯誤:android.content.Context無法提供@提供註釋的方法
@Inject
VideoControllerView mediaController;
@Module
public class PlayerModule {
@Provides
VideoControllerView providesVideoControllerView(Context context, VideoControllerView.Controlers cntrls) {
return new VideoControllerView(context, cntrls);
}
}
@Component(modules = PlayerModule.class)
public interface PlayerComponent {
VideoControllerView getVideoControllerView();
}
但是,當我試圖編譯我的應用程序,我得到如下錯誤:
Error:(14, 25) error: android.content.Context cannot be provided without an @Provides-annotated method.
android.content.Context is injected at
com.multitv.multitvplayersdk.module.PlayerModule.providesVideoControllerView(context, …)
com.multitv.multitvplayersdk.controls.VideoControllerView is provided at
com.multitv.multitvplayersdk.component.PlayerComponent.getVideoControllerView()
我已經環顧四周,就如何解決這個問題,但無濟於事。請幫幫我。
檢查https://stackoverflow.com/questions/30692501/dagger-2-injecting-android-context –
顯示代碼,在其中創建'PlayerComponent'。 – azizbekian
只有編譯完成後,我才能找到DaggerPlayerComponent。在這個時候,工作室甚至不允許我編譯 –