所以我有一个项目,我用Dagger进行依赖注入,但我想使用一个使用RoboGuice的库项目。
当我尝试运行它时,进入库项目时出现以下错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{PROJECT.debug/LIBRARY.Activity}: com.google.inject.CreationException: Guice creation errors:
1) Could not find a suitable constructor in PROJECT.AdvertisingTrackingAggregator. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
at PROJECT.AdvertisingTrackingAggregator.class(Unknown Source)
while locating PROJECT.AdvertisingTrackingAggregator
for field at PROJECT.ProjectApplication._advertistingTrackingAggregator(Unknown Source)
at roboguice.config.DefaultRoboModule.configure(DefaultRoboModule.java:141)
1 error
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2255)
....
Caused by: com.google.inject.CreationException: Guice creation errors:
1) Could not find a suitable constructor in PROJECT.AdvertisingTrackingAggregator. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
at PROJECT.AdvertisingTrackingAggregator.class(Unknown Source)
while locating PROJECT.AdvertisingTrackingAggregator
for field at PROJECT.ProjectApplication._advertistingTrackingAggregator(Unknown Source)
at roboguice.config.DefaultRoboModule.configure(DefaultRoboModule.java:141)
1 error
at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:435)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:154)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:83)
at roboguice.RoboGuice.setBaseApplicationInjector(RoboGuice.java:94)
at roboguice.RoboGuice.setBaseApplicationInjector(RoboGuice.java:139)
at roboguice.RoboGuice.getBaseApplicationInjector(RoboGuice.java:59)
at roboguice.RoboGuice.getInjector(RoboGuice.java:149)
at com.github.rtyley.android.sherlock.roboguice.activity.RoboSherlockFragmentActivity.onCreate(RoboSherlockFragmentActivity.java:31)
at LIBRARY.ui.activity.AbstractLibraryActivity.onCreate(AbstractLibraryActivity.java:149)
at LIBRARY.ui.activity.LibraryLandingActivity.onCreate(LibraryLandingActivity.java:68)
at android.app.Activity.performCreate(Activity.java:5720)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1102)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2208)
... 10 more
库是否需要使用Module进行自我配置,以避免通过Dagger查找我在项目中使用的@Inject注释?
如何通过Guice / Dagger战斗?