该问题不会发生在其他手机或模拟器上。
如果我使用命令行分别安装和启动应用程序,该应用程序运行良好:
./gradlew clean installMyApp && adb shell "am start -n com.abc.xyz/com.abc.xyz.activities.landing.splash.SplashScreen
在同一天,班级名称似乎是一致的。但是,当我隔几天再试时,这是一个不同的班级“失踪”
Stacktrace 截至 2017 年 10 月 30 日的今天:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.abc.xyz, PID: 24924
java.lang.NoClassDefFoundError: rx.android.schedulers.LooperScheduler
at rx.android.schedulers.AndroidSchedulers.from(AndroidSchedulers.java:63)
at com.abc.xyz.di.app.AppModule.provideLooperScheduler(AppModule.java:77)
at com.abc.xyz.di.app.AppModule_ProvideLooperSchedulerFactory.get(AppModule_ProvideLooperSchedulerFactory.java:15)
at com.abc.xyz.driver.di.app.AppModule_ProvideLooperSchedulerFactory.get(AppModule_ProvideLooperSchedulerFactory.java:8)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.abc.xyz.AppLogicComponent_Factory.get(AppLogicComponent_Factory.java:110)
at com.abc.xyz.AppLogicComponent_Factory.get(AppLogicComponent_Factory.java:23)
at dagger.internal.DoubleCheck.get(DoubleCheck.java:47)
at com.abc.xyz.MyApplication_MembersInjector.injectMembers(MyApplication_MembersInjector.java:167)
at com.abc.xyz.MyApplication_MembersInjector.injectMembers(MyApplication_MembersInjector.java:23)
at com.abc.xyz.di.app.DaggerAppComponent.inject(DaggerAppComponent.java:2865)
at com.abc.xyz.di.app.DaggerAppComponent.inject(DaggerAppComponent.java:842)
at dagger.android.DaggerApplication.injectIfNecessary(DaggerApplication.java:78)
at dagger.android.DaggerApplication.onCreate(DaggerApplication.java:53)
at com.abc.xyz.MyApplication.onCreate(MyApplication.java:81)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1017)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4996)
at android.app.ActivityThread.access$1600(ActivityThread.java:188)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1591)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:210)
at android.app.ActivityThread.main(ActivityThread.java:5839)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1113)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:879)
请注意,我不时看到许多不同且不相关的类“丢失”。这只是一个例子,不应该与问题本身有任何关系:(
使用 Dagger 2 进行依赖注入)
@ParametersAreNonnullByDefault
@Module(includes = NetModule.class)
class AppModule {
//...
@AppComponent.AppScope
@Provides
static Scheduler provideLooperScheduler() {
// Please be sure not to execute long run executions with this scheduler
// This scheduler is meant to be beneficial in timer/interval/retry/timeout/sample/window these rx.Operators
final HandlerThread handlerThread = new HandlerThread("RxLooperHandler");
handlerThread.start();
return AndroidSchedulers.from(handlerThread.getLooper());
}
//...
}