'can not access a member' exception
See original GitHub issueMy setup is :
public class RoboElectricDaggerMockRule extends DaggerMockRule<TestAppComponent> {
public RoboElectricDaggerMockRule() {
super(TestAppComponent.class, new AssistantUtilsModule());
customizeBuilder(new BuilderCustomizer<TestAppComponent.Builder>() {
@Override public TestAppComponent.Builder customize(TestAppComponent.Builder builder) {
return builder.application(getApp());
}
});
set(new DaggerMockRule.ComponentSetter<TestAppComponent>() {
@Override public void setComponent(TestAppComponent component) {
component.inject(getApp());
}
});
}
private static AnydoRobolectricTestApp getApp() {
return (AnydoRobolectricTestApp) RuntimeEnvironment.application;
}
}
My test configuration :
@RunWith(RobolectricTestRunner.class)
@Config(application = AnydoRobolectricTestApp.class,constants = BuildConfig.class, sdk = 21, shadows = { ShadowPreferenceHelper.class})
public class DeepLinkTestNew {
@Rule public RoboElectricDaggerMockRule rule = new RoboElectricDaggerMockRule();
@Mock
AssistantUtils assistantUtils;
@Test
`public void testSomething()`
public interface TestAppComponent extends AndroidInjector<AnydoRobolectricTestApp> {
@Override
void inject(AnydoRobolectricTestApp instance);
@Component.Builder
interface Builder {
Builder assistantUtilsModule(AssistantUtilsModule assistantUtilsModule);
@BindsInstance
TestAppComponent.Builder application(Application application);
TestAppComponent build();
}
}
But I get the following error :

“java.lang.IllegalAccessException: Class it.cosenonjaviste.daggermock.ObjectWrapper can not access a member of class com.anydo.di.components.DaggerTestAppComponent$Builder with modifiers “public””
TestAppComponent which is auto generated by Dagger has all fields private, so it makes sense. Am I missing something ?
And another question, is it mandatory to add a module setter like this inside the component?
Builder assistantUtilsModule(AssistantUtilsModule assistantUtilsModule);
it’s kinda boilerplate and would be great if we can remove.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
can not access a member of class org.springframework.aop ...
This class is not public itself. It is package protected (see here). You have to call setAccessible(true) before access its member exactly ...
Read more >can not access a member of class with modifiers "public"
I get this error: [quote]java.lang.IllegalAccessException: Class com.vaadin.data.util.MethodProperty can not access a member of class ...
Read more >Can not access a member of class X with modifiers "public ...
When upgrading from 1.4 to 1.5 none of my template is working anymore. For example : [javadoc] ERROR [console:logVelocityMessage] - ASTMethod.execute() ...
Read more >Troubleshooting (The Java™ Tutorials > The Reflection API ...
This reflection Java tutorial describes using reflection for accessing and ... IllegalAccessException: Class ClassTrouble can not access a member of class ...
Read more >System.MemberAccessException Class - GNU.org
MemberAccessException.Message property of the new instance to a system-supplied message that describes the error, such as "Cannot access member.
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 Free
Top 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

I have pushed a new version to fix this issue, I have tried here and it seems to work. Can you try the version cc0b0acd98 to confirm that this commit fixes your error as well? Thanks again for your help
I have just released version 0.8.2 to include this fix, thanks again for your report and for your help!