3

I am trying to run Systrace but I get an error when I run the command.

user1@PC1:~/Android/Sdk/platform-tools/systrace$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 
user1@PC1:~/Android/Sdk/platform-tools/systrace$ ls
AUTHORS  prefix.html         systrace.py
LICENSE  suffix.html         systrace_trace_viewer.html
NOTICE   systrace-legacy.py  UPSTREAM_REVISION
user1@PC1:~/Android/Sdk/platform-tools/systrace$ python systrace.py --time=10 -o mynewtrace.html 
Traceback (most recent call last):
  File "systrace.py", line 320, in <module>
    main()
  File "systrace.py", line 158, in main
    stderr=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 710, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

I am currently running Ubuntu with Android SDK 5.1.1 installed along with Android Studio. Below is are my PATH export in .bashrc:

export PATH="~/Applications/android-studio/bin/:$PATH"
export PATH="~/Android/Sdk/platform-tools/:$PATH"
export PATH="~/Android/Sdk/tools/:$PATH"
Zythyr
  • 1,142
  • 4
  • 20
  • 33
  • Sounds like it's having trouble finding "adb", though it looks like you've got the right path set up. If you just run "adb" is it found in your path? Try editing the script, before the `Popen` call add a `print >> sys.stderr, 'args are %s' % atrace_args` and see what it's trying to do. – fadden Jun 09 '15 at 05:02
  • @fadden I updated Python to v2.7.10 and also confirmed adb command works. When I type `adb devices`, I see my device listed. I added two print statements. One of `atrace_args` and one for `tracer_args`. Below is the output: `['atrace', '-z', '-t', '10', ';', 'ps', '-t'] tracer args are ['adb', 'shell', 'atrace -z -t 10 ; ps -t']` – Zythyr Jun 10 '15 at 22:38

2 Answers2

5

Even though the answer is accepted, for those who face this problem in the future;

Run systrace from /platform-tools directory(adb is in /platform-tools directory) not from /platform-tools/systrace directory. E.g.

.../platform-tools$ python systrace/systrace.py
OldWolfs
  • 606
  • 6
  • 15
2

I fixed the issues by changing my PATH export to be specified by absolute path instead of relative path. This means, I can't define my home directory using ~/..., I have to use /home/username/....

export PATH="/home/user1/Applications/android-studio/bin/:$PATH"
export PATH="/home/user1/Android/Sdk/platform-tools/:$PATH"
export PATH="/home/user1/Android/Sdk/tools/:$PATH"

However, it is not clear to me why systrace.py won't properly run when PATH is defined using ~/... instead of /home/username/.... ADB works perfectly fine when the PATH is defined using ~/....

Zythyr
  • 1,142
  • 4
  • 20
  • 33