You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Define a class like this, and inject it in classes, if this class is in the same app module, it will success, but if move this class to a library module, it will fail. Exception is:
com.google.inject.CreationException: Unable to create injector, see the following errors:
Could not find a suitable constructor in com.lenovo.shareit.Test1. Classes must have either one (and only one) constructor annotated with @Inject or a zero-argument constructor that is not private.
at com.lenovo.shareit.Test1.class(Unknown Source)
while locating com.lenovo.shareit.Test1
for field at com.lenovo.shareit.ShareitApp.test(Unknown Source)
at roboguice.config.DefaultRoboModule.configure(DefaultRoboModule.java:166)
1 error
-----------------------------------------------------------source code being injected.
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.lenovo.shareit.common.EventBusToken;
import org.greenrobot.eventbus.EventBus;
/**
Created by Wallace on 3/3/2016.
*/
public class Test { @Inject
public Test(@nAmed(EventBusToken.Common)EventBus bus){
System.out.println("bus="+bus);
}
public static void test1(){
System.out.println("Test::test1::v2");
}
public void testNoneStatic(){
System.out.println("Test::no static method::v1");
}
}
The text was updated successfully, but these errors were encountered:
Define a class like this, and inject it in classes, if this class is in the same app module, it will success, but if move this class to a library module, it will fail. Exception is:
com.google.inject.CreationException: Unable to create injector, see the following errors:
at com.lenovo.shareit.Test1.class(Unknown Source)
while locating com.lenovo.shareit.Test1
for field at com.lenovo.shareit.ShareitApp.test(Unknown Source)
at roboguice.config.DefaultRoboModule.configure(DefaultRoboModule.java:166)
1 error
-----------------------------------------------------------source code being injected.
import com.google.inject.Inject;
import com.google.inject.name.Named;
import com.lenovo.shareit.common.EventBusToken;
import org.greenrobot.eventbus.EventBus;
/**
Created by Wallace on 3/3/2016.
*/
public class Test {
@Inject
public Test(@nAmed(EventBusToken.Common)EventBus bus){
System.out.println("bus="+bus);
}
public static void test1(){
System.out.println("Test::test1::v2");
}
public void testNoneStatic(){
System.out.println("Test::no static method::v1");
}
}
The text was updated successfully, but these errors were encountered: