I'm new to the dagger. I am currently creating a sample project for some abbreviations:
MyComponent.java
@PerActivity @Component(modules = MyModule.class) public interface MyComponent { void inject(TutorialActivity activity); }
Mymodule.java
@Module public class MyModule { @Provides Position providePosition() { return new Position(); } }
PerActivity.java
@Scope @Retention(RUNTIME) public @interface PerActivity {}
TutorialActivity.java
public class TutorialActivity extends AppCompatActivity{}
When compiling a project, I get an error:
Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > java.lang.IllegalArgumentException: expected one element but was: <android.support.v4.app.FragmentActivity, android.support.v4.app.TaskStackBuilder.SupportParentable>
So, if I change the TutorialActivity as:
public class TutorialActivity extends Activity{} or even public class TutorialActivity{}
Then it will work fine (I see a class created by Dagger2).
Please, help!
Thanks.
UPDATE
My project structure:
common .app . (the application module will use the general module as defined in gradle).
In both build.gradle (generic and application module) I added:
apt "com.google.dagger:dagger-compiler:${daggerVersion}" compile "com.google.dagger:dagger:${daggerVersion}"
In build.gradle in the general module:
provide "org.glassfish:javax.annotation:${javaxAnnotationVersion}"
The error only occurs if I have 2 modules. ( app module depends on common ). If I translate my component / module into a common module -> It works. But when I go to the app module -> Error compiling.
source share