IllegalArgumentException with TestComponent extends ApplicationComponent
See original GitHub issueI have a public project where I’m experimenting with the latest libraries for Android, and which is targeting Nougat (minSdk 24). It’s using Jack and the new annotationProcessor
(and androidTestAnnotationProcessor
). I have the following:
// In main sourceSet
@Singleton
@Component(modules = PresenterModule.class)
public interface StopwatchComponent {
void inject(StopwatchFragment stopwatchFragment);
}
// In androidTest sourceSet
@Singleton
@Component(modules = TestModule.class)
public interface TestStopwatchComponent extends StopwatchComponent {
void inject(StopwatchFragmentTest test);
}
When I run ./gradlew assembleDebugAndroidTest
, I get the following error:
* What went wrong:
Execution failed for task ':app:transformJackWithJackForDebugAndroidTest'.
> com.android.jack.ir.JNodeInternalError: java.lang.Exception: java.lang.IllegalArgumentException: element public abstract void inject(com.autonomousapps.reactivestopwatch.ui.StopwatchFragment) is not a member of the containing type com.autonomousapps.reactivestopwatch.di.TestStopwatchComponent nor any of its superclasses
If I change TestStopwatchComponent as follows, the error goes away:
@Singleton
@Component(modules = TestModule.class)
public interface TestStopwatchComponent extends StopwatchComponent {
void inject(StopwatchFragment fragment); // new
void inject(StopwatchFragmentTest test);
}
I don’t believe this should be necessary. After all, TestStopwatchComponent extends StopwatchComponent, which defines that injection. I’ve used this pattern in other projects, and it works fine. Either I’m overlooking an obvious bug, or there’s a real issue in dagger/jack/annotationProcessor. I appreciate any help you can offer.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:8
Top Results From Across the Web
Dagger 2 injection in Android instrumentation tests
It works perfectly fine for Classes/Activities/Fragments in the main application component, but my test component seems to be missing some ...
Read more >Diff - platform/cts - Google Git
-public class AudioFrequencyLineActivity extends PassFailButtons. ... fail("Expected IllegalArgumentException when serializing an empty report"); ...
Read more >Fancy Fragment = FragmentFactory+Dagger | by MJ Studio
We extended FragmentFactoy class and overrided instantiate method. It's time to inject our first FragmentFactory with Dagger.
Read more >Binder.java - Android Code Search
application component (a {@link android.app. ... that extend this Binder class and that are not static. These kind ... throw new IllegalArgumentException();. }....
Read more >Java Examples for org.restlet.Component - Javatips.net
This java examples will help you to understand the usage of org.restlet.Component. These source code samples are taken from different open source projects....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I actually ran into this issue yesterday when attempting to upgrade to java 8 in android. I am using a base ActivityComponent(with Activity injector) interface that I extend from smaller components(ChildComponent) interfaces like this:
I am using the latest stable android plugin 2.2.0 and Dagger 2.7 release with the annotationProcessor notation instead of apt plugin from the android plugin.
To me it looks like a bug in the way dagger is doing validation with the jack compiler, something doesn’t correctly interpret interface inheritance correctly, I also tried using component dependency from the ChildComponent and removing the extend portion and still get the same message.
Here is the stacktrace I see in gradle CLI:
Same problem here
`Error:Execution failed for task ‘:app:transformJackWithJackForDebugAndroidTest’.
Should Dagger fix that or should the Android Team fix that?
What do you suggest for quick fixing the issue in my project? I need Java 8.