10

I have been learning how to use Systrace following instructions on how to use Systrace (from the Android Developers website). I've tried using both the GUI and the Terminal (command line).

Using the GUI:

I received an error after the trace had finished and was being saved. I clicked on the 'Details' button and overall, was given the following message:

Unable to collect system trace

Reason: Unexpected error while collecting system trace.

Conversion = ';'

The Systrace file was not saved.

Using the command line:

I've tried using the command line as well using the GUI (although I'm new to using the command line).
Typing $ cd android-sdk/platform-tools/systrace or $ python systrace.py into the command line returns the error:

'$' is not recognized as an internal or external command, operable program or batch file.

Using cd android-sdk/platform-tools/systrace (without the $ character) gives this error:

The system cannot find the path specified.

And using python systrace.py (again, without the$ this time) returns this error:

'python' is not recognized as an internal or external command, operable program or batch file.

Am I missing something out, or is it something that needs to be reconfigured?

Farbod Salamat-Zadeh
  • 19,687
  • 20
  • 75
  • 125
  • 1
    Have you tried the command-line tools? http://developer.android.com/tools/help/systrace.html http://developer.android.com/tools/debugging/systrace.html – fadden Jun 07 '15 at 15:49
  • @fadden I just tried that out. See my updated answer. – Farbod Salamat-Zadeh Jun 07 '15 at 20:25
  • 1
    The '$' indicates the command prompt, you don't type it. You need to switch to the root directory of the SDK before typing the commands. Search for a directory called "android-sdk" if you don't know where that is. – fadden Jun 07 '15 at 21:24
  • @fadden Thanks. I switched to the root directory, but after switching, I tried typing `python systrace.py --time=15 -0 myTrace.html sched view wm am res dalvik membus load`, but I received the error _'python' is not recognised as an internal or external command, operable program or batch file_. – Farbod Salamat-Zadeh Jun 08 '15 at 16:58
  • Sounds like you need to install a Python runtime. – fadden Jun 08 '15 at 19:59
  • @fadden I already have Python installed. Do I need a specific version of it? – Farbod Salamat-Zadeh Jun 09 '15 at 14:55
  • Sounds like it's not in your PATH then. – fadden Jun 09 '15 at 15:11
  • @fadden What exactly do you mean and how would I solve this issue? I have tried reinstalling Python with the option _Add python.exe to Path_ (see [this image](http://i.imgur.com/fIRcWhC.jpg)), but I am still getting the same error when I run Systrace in Android Studio. – Farbod Salamat-Zadeh Jun 12 '15 at 20:12
  • 1
    The PATH is a list of directories that are searched for executable files. If the shell you're running is configured with a PATH that does not include python.exe (assuming Windows), then when you type "python" it doesn't know what to do. You can try typing the full path to the python executable, or you can figure out how your shell environment is configuring PATH and try to determine why it's unable to find python.exe. – fadden Jun 13 '15 at 00:06
  • @fadden Thanks. It solved that particular error but I am now getting a different error (updated in answer) – Farbod Salamat-Zadeh Jun 13 '15 at 01:28
  • 1
    My first guess would be that the python executable is unable to find `adb.exe` in the PATH. The systrace script uses that to communicate with the device. – fadden Jun 13 '15 at 15:14
  • @fadden Thank you so much! I finally fixed this issue. :D – Farbod Salamat-Zadeh Jun 13 '15 at 22:19

1 Answers1

5

I finally fixed my issue following @fadden's guidance in the comments.

I used the command prompt to find out what my issues were, but my problem was also fixed for the GUI. Here's how I did it:

  1. First, install Python if it's not already installed. I reinstalled it selecting the option: Add python.exe to Path (as in this image). I used Python 2 as I'm not sure how it would work with Python 3.

  2. Next, edit environmental variables. You can do this (on Windows 8) by going to Control Panel -> System -> Advanced System Settings -> Environment Variables. Under 'System variables', scroll down to 'Path' and click the 'Edit' button.

  3. Add Python to the Path by adding the address for the location of your Python installation followed by a semicolon to the start of the Variable value.
    For example, I added C:\Python27\; to the start of the 'Variable value'. (Note: Do not delete/remove anything from the 'Variable value' textbox, just add to it).

  4. Add adb.exe to Path as well by adding the address for the location of the file adb.exe similar to how you added Python to the path.
    It should be something similar to C:\Users\MyName\Android-SDK\platform-tools;.

  5. Click 'OK' on the dialogs and restart your computer for the changes to take effect. You should now be able to use Systrace using the GUI and command line without this error.

Community
  • 1
  • 1
Farbod Salamat-Zadeh
  • 19,687
  • 20
  • 75
  • 125
  • 1
    @YetAnotherUser I already mentioned that though in step 1. If you mean that it has been downvoted because it only works with python 2, it should still not be downvoted as it is a solution to the question nonetheless. – Farbod Salamat-Zadeh Sep 18 '15 at 15:05