Saving Logcat to a text file in Android Device

前端 未结 7 1763
时光取名叫无心
时光取名叫无心 2020-12-02 08:16

I had found some crashes while running the application in android device, which is not showing in emulator. So i need to save the Logcat in a text file in my device\'s memor

7条回答
  •  悲哀的现实
    2020-12-02 08:43

    Use -f option with logcat in your class:

    Runtime.getRuntime().exec("logcat -f" + " /sdcard/Logcat.txt");
    

    This will dump the logs to the file stored device.

    Note that the path "/sdcard/" may not be available in all devices. You should use the standard APIs to access the external storage.

提交回复
热议问题