1

当我使用 RoboGuice2.0 注入一些模块时,我得到一个像这样的 ArrayIndexOutOfBoundsException

Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.util.ArrayList.add(ArrayList.java:129)
at com.google.inject.internal.ap.a(Unknown Source)
at com.google.inject.internal.da.b(Unknown Source)
at com.google.inject.internal.da.a(Unknown Source)
at com.google.inject.internal.da.a(Unknown Source)
at com.google.inject.internal.da.a(Unknown Source)
at com.google.inject.internal.da.a(Unknown Source)
at com.google.inject.internal.bn.a(Unknown Source)
at com.google.inject.internal.InternalInjectorCreator.build(Unknown Source)
at com.google.inject.Guice.createInjector(Unknown Source)
at com.google.inject.Guice.createInjector(Unknown Source)
at roboguice.RoboGuice.setBaseApplicationInjector(Unknown Source)
at com.sankuai.movie.MovieApplication.onCreate(Unknown Source)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:984)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3825)

我像这样使用了 setBaseApplicationInjector。

List<Module> modules = new ArrayList<Module>();
    modules.add(new DefaultNetModule(Consts.BASE_URL));
    modules.add(new DefaultLocationModule(this, false, null, 30000, 5000,
            10000));
    modules.add(new UpdateDownloadModule(this, "movie",
            BaseConfig.sChannel, BaseConfig.sVersionCode,
            BaseConfig.sVersionName, null));
    modules.add(new MovieModule());
    modules.add(new AccountModules(getApplicationContext()));
RoboGuice.setBaseApplicationInjector(this, Stage.DEVELOPMENT, Modules
            .override(RoboGuice.newDefaultRoboModule(this)).with(modules));

很可能是 RoboGuice2.0 源代码中我在 List 中添加内容时发生的。但是在使用 list.add 方法时似乎不可能抛出 ArrayIndexOutOfBoundsException。我想知道我的用法是否正确以及解决此问题的方法。

4

0 回答 0