I need the bugreport option that you can use in adb to go to a file on the sd in my app. I foundAndroid; using exec("bugreport")that explains that you can not run bugreport in the regular shell and that you need to run dumpstate, dumpsys, and logcat separately to get the same result. That is fine and I understand that, but I can not get dumpstate or dumpsys to write to the file. The below works fine to write the logcat using logcat -d -f, but does not work for the other two. I have tried dumpstate -f , dumpstate -d -f and dumpstate > to get it work, but still does not write anything to the file. Is there something I am missing to make this work?
This is where I am creating the file on the sd
File folder = new File(Environment.getExternalStorageDirectory()+"/IssueReport/");
if (folder.isDirectory() == false) {
folder.mkdir();
}
log = new File(Environment.getExternalStorageDirectory()+"/IssueReport/log.txt");
and here is where I am writing the file to the location
private void submit() {
try {
log.createNewFile();
String cmd = "dumpstate "+log.getAbsolutePath();
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
}
文章详细介绍了如何在Android应用中使用Java代码执行bugreport命令,并将其输出到SD卡上的特定文件中。通过创建并运行自定义的shell命令,实现了将dumpstate、dumpsys和logcat报告整合到一个文件内的解决方案。

被折叠的 条评论
为什么被折叠?



