diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index af69b040a..081ff74cb 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -122,11 +122,11 @@ public class AppContext extends CommonAppContext { @Override public void onCreate() { super.onCreate(); - //注册全局异常捕获 if (!isMainProcess()) { return; } CrashSaveBean.getInstance().setStartTime(System.currentTimeMillis()); + //注册全局异常捕获 registerError(); registerFirebaseCrash(); LogUtils.start(this); diff --git a/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java b/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java index 87c8f3124..b2dc80e1c 100644 --- a/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java +++ b/app/src/main/java/com/shayu/phonelive/utils/LogUtils.java @@ -31,7 +31,7 @@ public class LogUtils { String[] exec = new String[]{"logcat", "-c"}; Runtime.getRuntime().exec(exec).waitFor(); - exec = new String[]{"logcat", "-v", "UTC", "-D"}; + exec = new String[]{"logcat", "-v", "color", "UTC-8"}; Process process = Runtime.getRuntime().exec(exec); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); @@ -55,6 +55,7 @@ public class LogUtils { writer = new PrintWriter(os); while ((line = bufferedReader.readLine()) != null) { writer.append(line).write("\n"); + writer.flush(); } writer.flush(); writer.close();