0

I'm not good at English, so I'm asking through translation.

Please understand even if the grammar is weird.

Developed USB communication App.

But often shutdowns are occurring.

We cannot find the cause because it is not a termination phenomenon due to a specific action.

Debugging is not possible because a USB communication device is connected.

Even if it is applied to most actions to create a log.txt file with a try-catch statement, it is not recorded in the log.

I also wrote a code for when the app is forcibly closed.

Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler());

    class ExceptionHandler implements Thread.UncaughtExceptionHandler {
    @Override
    public void uncaughtException(Thread t, Throwable e) {
        try {
            BufferedWriter buf = new BufferedWriter(new FileWriter(filePath+"/Log.txt", true));
            buf.append("Error!! : "+e.getMessage());
            buf.close();
        } catch (FileNotFoundException ee) {
            ee.printStackTrace();
        } catch (IOException ee) {
            ee.printStackTrace();
        }

        e.printStackTrace();
        android.os.Process.killProcess(android.os.Process.myPid());
        System.exit(10);
    }
}

Even if I do this, it is not recorded in the log. Please advise on other methods.

hyeong
  • 1
  • 1
  • It looks like this answers your question: https://stackoverflow.com/questions/20763011/android-saving-logs-on-every-run-for-crash-report - your code is similar but this example works. – user3252344 Jan 19 '22 at 03:51
  • 1
    Unclear if you tried to debug using [adb over wifi](https://stackoverflow.com/q/4893953/295004) while having USB communication device connected to device. – Morrison Chang Jan 19 '22 at 06:00

0 Answers0