0

I run tests on multiple devices with ADB in parallel:

adb -s 11.11.11.111:5555 shell "CLASSPATH=$(pm path androidx.test.services) app_process / androidx.test.services.shellexecutor.ShellMain am instrument -r -w -e targetInstrumentation com.my.app.debug.test/androidx.test.runner.AndroidJUnitRunner -e clearPackageData true  -e numShards 2 -e shardIndex 0 -e debug false androidx.test.orchestrator/androidx.test.orchestrator.AndroidTestOrchestrator" &
adb -s 11.11.11.112:5555 shell "CLASSPATH=$(pm path androidx.test.services) app_process / androidx.test.services.shellexecutor.ShellMain am instrument -r -w -e targetInstrumentation com.my.app.debug.test/androidx.test.runner.AndroidJUnitRunner -e clearPackageData true  -e numShards 2 -e shardIndex 1 -e debug false androidx.test.orchestrator/androidx.test.orchestrator.AndroidTestOrchestrator" &
wait

If a test fails, an error message / stacktrace is usually displayed, but not always. Therefore it would be helpful to save the logs of the app in a file. I tried the following command after the tests were finished:

adb -s 11.11.11.111:5555 logcat | grep "com.my.app.*" > app/build/reports/logcat.txt

But the command saves only the system logs in the file and not the logs which I can normally see when running the tests in Android Studio (in the logcat window of Android Studio).

manu
  • 183
  • 1
  • 12

1 Answers1

0

You probably just forget to add -s 11.11.11.11x:5555 option on adb logcat.

adb -s 11.11.11.111:5555 logcat | grep "com.my.app.*" > app/build/reports/logcat1.txt
adb -s 11.11.11.112:5555 logcat | grep "com.my.app.*" > app/build/reports/logcat2.txt
Guillaume P
  • 371
  • 2
  • 8
  • This is not the reason. I have this in my script. The problem is, that after the tests are done the logcat command does not deliver the logs of the app. Only system logs are available and this is not useful. When I run a test and start logcat in parallel, I can see the relevant logs. But when the test is done and I start logcat than the specific logs of the app are not available anymore. – manu May 03 '21 at 21:43
  • So maybe it's just releated to logcat buffer. You ask logcat too late to get application logs. You can try to increase logcat buffer with : adb logcat -g 12M – Guillaume P May 04 '21 at 07:16
  • Hm. Now, I think the logs are there. I did not see them because the logcat output contains so many other logs and the package name is not displayed. So it is very confusing. I tried this: "adb -d logcat com.mypackagename:I" but there are still so many other logs I do not need. Do you know how I can use logcat to get only the logs of my app and how to display the packagename too? – manu May 04 '21 at 08:21