简体   繁体   English

在独立的 android 库项目中使用匕首 2

[英]Using dagger 2 in stand alone android library project

I am trying to create a stand alone library and use dagger 2 in it, I already create the module and the component of the library, and make the initialisation of the library including the dagger component, my goal here is I wanted this library can be used even the project who implemented it did not use dagger.我正在尝试创建一个独立的库并在其中使用 dagger 2,我已经创建了库的模块和组件,并对包括 dagger 组件在内的库进行了初始化,我的目标是我希望这个库可以甚至实施它的项目都没有使用匕首。 but it seems my configuration only can work if the project implemented it, also use dagger2 cause I got error:但似乎我的配置只有在项目实现它时才能工作,也使用 dagger2 因为我得到错误:

Application does not implement dagger.android.HasDispatchingActivityInjector

So are there anyway I can still dagger2 in my library without having the project who implemented it also use dagger2?那么无论如何我仍然可以在我的库中使用 dagger2 而无需实现它的项目也使用 dagger2?

ps: My library contain an activity ps:我的图书馆包含一个活动

It was because of missing android:name key with the value of my Application subclass to my manifest file .这是因为缺少 android:name 键以及我的 Application 子类的值到我的清单文件

Eg: Add android:name=". MyApplication " in your manifest under application tag.例如:在应用程序标签下的清单中添加android:name=". MyApplication " Change the 'MyApplication' to the name of your application class将“MyApplication”更改为您的应用程序名称 class

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM