Sachin
Sachin

Reputation: 2697

How do i run the Android command line tools?

I'm still pretty new to Android and programming in general, and I can't seem to get the command line tools packaged with the Android SDK to work. I'm running Mac OSX and each time I try to run layoutopt, for example, the terminal returns, *-bash: cmd: command not found *

Also, is it okay to have my SDK located in the Developer directory and my android project in some unrelated directory when using these tools?

Upvotes: 12

Views: 16642

Answers (6)

Daniel Earwicker
Daniel Earwicker

Reputation: 116714

The current (2016-08-17) answer to this question is:

~/Library/Android/sdk

So my bash_profile contains:

export ANDROID_HOME=~/Library/Android/sdk
export PATH=${PATH}:$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools

Upvotes: 1

NKijak
NKijak

Reputation: 1172

If you want you can put the path in your ~/.bash_profile so you can call it from anywhere:

export ANDROID_HOME=/Users/<username>/path/to/sdk/tools

export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Upvotes: 14

jgatjens
jgatjens

Reputation: 686

You may want to include also the platform-tools into your ~./bash_profile

### Android dev tools
export ANDROID_HOME="/Users/myusername/DEV/tools/adt-bundle-mac-x86_64/sdk"
export PATH="$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH"

You will need to start a new terminal session or run

source ~/.bash_profile

to loads the values immediately without having to open a new terminal session.

Upvotes: 4

Igor Čordaš
Igor Čordaš

Reputation: 5964

Problem is your command line tool is not seeing required programs from /path/to/sdk/tools. One solution as user NKijak mentioned is to add those tools to your Home path and the other is to run command line from location where your sdk tools are stored. Here is a tutorial how to do just that http://hathaway.cc/2008/06/how-to-edit-your-path-environment-variables-on-mac-os-x/ Other way is, when opening command line just change your current dir to /path/to/sdk/tools and then run the tools. In windows you can just shift+right click in file explorer and pick open command windows here I am not sure is there equivalent on MacOS but there are some extensions you can install to add this option. Also total commander in windows has command line where you can start command line from current location there are similar programs on mac like Midnight Commander that have same option.

Upvotes: 0

Sachin
Sachin

Reputation: 2697

I figured it out. I needed to go to the /tools directory in the SDK folder and type in:

./layoutopt <directorypath>

Upvotes: 0

anon
anon

Reputation:

Here is a good description:

To connect to the console of any running emulator instance at any time, use this command:

telnet localhost <console-port>

Upvotes: -1

Related Questions