Search code examples
androidpythonlinuxadbsystrace

Error when trying to use Android systrace.py on Linux Ubuntu


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"

Solution

  • 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 ~/....