崩溃
yuanjize opened this issue · comments
第一次进去,没有写笔记,只按了一下camera,由于相机的问题崩溃了。
第二次进去 isFirstTime()判断为true,接着调用Observable.from(new File(FilePathUtils.getPath()).listFiles()),但是我之前只点了一下相机按钮,没做别的所以.listFiles()为null,之后就出现空指针异常然后崩溃了。这里感觉应该判空一下
private void checkDisks() {
if (!mLocalStorageUtils.isFirstTime()) {
Observable.from(new File(FilePathUtils.getPath()).listFiles())
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.computation())
.filter(file1 -> !file1.isDirectory())
.filter(file -> file.getName().toLowerCase().endsWith(".jpg") ||
file.getName().toLowerCase().endsWith(".png") ||
file.getName().toLowerCase().endsWith(".jpeg"))
.count()
.subscribe(fileNumber -> {
mRxSandBox.getNumber()
.subscribe(new Action1<Integer>() {
@Override
public void call(Integer dbNumber) {
if (fileNumber != dbNumber) {
Intent checkIntent = new Intent(mContext, CheckService.class);
mContext.startService(checkIntent);
}
}
});
});
}
}
启动崩溃,以下是日志:
Caused by: java.lang.RuntimeException: MethodsTracingManager must be initialized by init(..)
at com.frogermcs.androiddevmetrics.internal.MethodsTracingManager.checkInitialized(MethodsTracingManager.java:90)
at com.frogermcs.androiddevmetrics.internal.MethodsTracingManager.shouldTraceMethod(MethodsTracingManager.java:84)
at com.frogermcs.androiddevmetrics.aspect.ActivityLifecycleAnalyzer.executeWithTracingIfEnabled(ActivityLifecycleAnalyzer.java:77)
at com.frogermcs.androiddevmetrics.aspect.ActivityLifecycleAnalyzer.ajc$inlineAccessMethod$com_frogermcs_androiddevmetrics_aspect_ActivityLifecycleAnalyzer$com_frogermcs_androiddevmetrics_aspect_ActivityLifecycleAnalyzer$executeWithTracingIfEnabled(ActivityLifecycleAnalyzer.java:1)
at com.frogermcs.androiddevmetrics.aspect.ActivityLifecycleAnalyzer.logAndExecute(ActivityLifecycleAnalyzer.java:66)
at com.yydcdut.note.views.home.impl.SplashActivity.onCreate(SplashActivity.java:29)
at android.app.Activity.performCreate(Activity.java:6070)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1125)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2604)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2715)
at android.app.ActivityThread.access$800(ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1579)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:199)
at android.app.ActivityThread.main(ActivityThread.java:5783)
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:982)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:777)
@ThinkingInMe
将 NoteApplication 中的 AndroidDevMetrics.initWith(this);
取消注释就好了
跟踪了下代码 在Application中看到了 谢谢