简体   繁体   English

如何查看 Android Orchestrator 日志?

[英]How to see the Android Orchestrator log?

I have a failing test in my suite and now I am using the Android Orchestrator, but all I get is this message:我的套件中有一个失败的测试,现在我正在使用 Android Orchestrator,但我得到的只是以下消息:

Test instrumentation process crashed.测试仪器进程崩溃。 Check com.something.something_detail.SomeActivityTest#testAddSucceeds_activityIsFinished.txt for details检查 com.something.something_detail.SomeActivityTest#testAddSucceeds_activityIsFinished.txt 了解详情

I don't know how to access that file.我不知道如何访问该文件。 Any help?有什么帮助吗?

You'll find them on the device under /data/data/android.support.test.orchestrator/files/ .您可以在设备上的/data/data/android.support.test.orchestrator/files/下找到它们。

To get them off the device via ADB (requires debugging enabled and either a rooted device or an emulator so you have root):要通过 ADB 将它们从设备上移除(需要启用调试以及有 root 权限的设备或模拟器,以便您拥有 root 权限):

adb root
adb pull /data/data/android.support.test.orchestrator/files/

Non-root, AndroidX users can use:非 root 用户,AndroidX 用户可以使用:

adb shell run-as androidx.test.orchestrator cat /data/user_de/0/androidx.test.orchestrator/files/com.pkg.name#testName.txt

My results show something slightly different than the other answers floating around SO.我的结果显示与围绕 SO 浮动的其他答案略有不同。

Using Android Studio IDE使用 Android Studio IDE

It seems that stock emulator images are basically rooted by default, except for images that support the Google Play Store.除了支持 Google Play 商店的图像,似乎股票模拟器图像在默认情况下基本上是植根的。 So try to run the failing test on a normal emulator and after you get the error I've been able to find the txt file through Android Studio's Device File Explorer tool.因此,尝试在普通模拟器上运行失败的测试,在出现错误后,我已经能够通过 Android Studio 的设备文件资源管理器工具找到 txt 文件。

Open the tool window and browse to /data/user_de/0/android.support.test.orchestrator/files/ and find your .txt file.打开工具窗口并浏览到/data/user_de/0/android.support.test.orchestrator/files/并找到您的 .txt 文件。

From here you can open the file or right-click to download it.从这里您可以打开文件或右键单击以下载它。 No need to for any terminal adb root commands, etc.不需要任何终端adb root命令等。

Alternate method (command line)替代方法(命令行)

If you insist on using adb and the command line then you must first:如果您坚持使用adb和命令行,那么您必须首先:

adb root
adb pull /data/user_de/0/android.support.test.orchestrator/files/ [directory to save to]
adb unroot (optional)

Thoughts想法

Unfortunately if you were hoping for a stack trace or something useful in the .txt file you might be highly disappointed.不幸的是,如果您希望在 .txt 文件中获得堆栈跟踪或有用的东西,您可能会非常失望。 All I found in my experience was something like:我在我的经验中发现的所有东西是这样的:

INSTRUMENTATION_RESULT: shortMsg=Process crashed.
INSTRUMENTATION_CODE: 0

which of course is quite useless for debugging.这当然对调试毫无用处。 :( :(

I'm also not sure if the file location differs for actual devices since all the other answers out there say the file is located at /data/data/... instead of /data/user_de/... which is what I have found for emulators.我也不确定实际设备的文件位置是否不同,因为那里的所有其他答案都说文件位于/data/data/...而不是/data/user_de/...这就是我所拥有的为模拟器找到。

In my case the file was useless as it only had在我的情况下,该文件是无用的,因为它只有

INSTRUMENTATION_RESULT: shortMsg=Process crashed.
INSTRUMENTATION_CODE: 0

On the plus side, this informed me that my testing application crashed.从好的方面来说,这告诉我我的测试应用程序崩溃了。 Looking in the logcat showed the stack trace as to why it crashed.查看 logcat 显示了有关崩溃原因的堆栈跟踪。

For anyone who still stumbles upon this, this Stack Overflow answer was helpful.对于仍然偶然发现这一点的任何人, 这个Stack Overflow 的回答很有帮助。 Pulling the files off of the emulator I was running required running adb as root first.从我正在运行的模拟器中提取文件需要首先以 root 身份运行 adb。

adb root

and then然后

adb pull /data/data/android.support.test.orchestrator/files/

For anyone using AndroidX Test Orchestrator, the path would change to对于使用AndroidX Test Orchestrator 的任何人,路径将更改为

adb pull /data/data/androidx.test.orchestrator/files/

but, this command also found 0 files so I had to use但是,这个命令也找到了 0 个文件,所以我不得不使用

adb pull /data/user_de/0/androidx.test.orchestrator/

I was facing the same error and when I checked the txt file on the device, I did not find meaningful logs.我遇到了同样的错误,当我检查设备上的 txt 文件时,我没有找到有意义的日志。 Then, I changed the "Build Variant" in my Android Studio and the setup started working.然后,我在我的 Android Studio 中更改了“Build Variant”并且设置开始工作。

You need to have rooted device to achieve this, so create emulator with system without google play services (they are rooted by default).你需要有root设备才能实现这一点,所以在没有google play服务的情况下创建带有系统的模拟器(默认情况下它们是root的)。 In the emulator with this kind of system you will find txt files in path:在具有这种系统的模拟器中,您将在路径中找到 txt 文件:

data/user_de/0/android.test.orchestrator/files数据/user_de/0/android.test.orchestrator/files

But I also did not find any useful info there.但我也没有在那里找到任何有用的信息。

For me, running instrumentation tests using the Android Test Orchestrator on emulators always resulted in the mysterious "Test instrumentation process crashed" failure.对我来说,在模拟器上使用 Android Test Orchestrator 运行仪器测试总是导致神秘的“测试仪器进程崩溃”失败。 I switched over to using a 64 bit emulator instead, and now the tests run.我改为使用 64 位模拟器,现在测试运行。 https://github.com/android/android-test/issues/352 https://github.com/android/android-test/issues/352

Android Studio AVD Manager 选择系统镜像

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM