PrototypeZ / AppJoint

🔧 Cross module Android development made easy!
764 stars 120 forks source link

AppJoint.service 报错,routersMap是空的 #43

Open tianyingzhong opened 3 years ago

tianyingzhong commented 3 years ago

W/System.err:java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.Class.newInstance()' on a null object reference W/System.err: at io.github.prototypez.appjoint.AppJoint.service(AppJoint.java:86) W/System.err: at io.github.prototypez.appjoint.AppJoint.service(AppJoint.java:79) debug发现routersMap是空的

public static synchronized <T> T service(Class<T> routerType, String name) {
    T requiredRouter = (T) get().getRouterInstanceMap().get(routerType, name);
    if (requiredRouter == null) {
        try {
            requiredRouter = (T) get().routersMap.get(routerType, name).newInstance();
            get().getRouterInstanceMap().put(routerType, name, requiredRouter);
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
    }
    return requiredRouter;
}