Blog Archives

adb devices reporting Nexus 7 offline

Occasionally run into a problem when switching devices (unplugging one device and plugging in a different one to collect logcat information), “adb devices” reports my Nexus 7 (running 4.2.2) as offline.  Bouncing the adb service (adb kill-server, adb start-sever) doesn’t fix it, either use unplugging the device and plugging it back in.  So far, one method (discovered by accident seems to work the best) – putting my mac to sleep (this often happens due to having to attend meetings) when I return and run “adb devices” again,the Nexus 7 is no longer offline – wacky but it least it works.  Will try putting the mac to sleep on purpose next time to see if it works.


Doing it all on a Mac (osx)

Mobile testing at a new company, the catch is I am not on a Mac, I have the commands (adb) work the same as before, but getting the Android SDK stuff to run is a bit different than I am used too (since I configured everything on windows before) at least I shouldn’t have to worry about Windows USB drivers this time around.

I downloaded the latest Android SDK from the Android site and made a point to ignore the eclipse instructions, I am not a developer and I dislike eclipse.  I unzipped the osx and then moved it to a different directory /Users/me/Android/…..  (use what ever works for you)

Now to run things like the SDK or the AVD you can type the command “android sdk” – if the path is setup, the android “tool” is in this directory: /sdk/tools, if your path isn’t setup you can cd to that directory and run the command locally:

  • ./android sdk – to download drivers and such
  • ./android avd – to create new virtual devices

If you set your path (so the system can find the commands) you can run this and other commands easier.

To check what your path is currently set too, you can use the command (you have to run this in a terminal, the linus/osx equivalent to a command prompt:

  • echo $PATH

You can also see what is configured in the paths file, or in the paths.d directory

  • more /etc/paths
  • ls -l /etc/paths.d

Some info about managing paths is here – though it might vary on some older osx installs.

For myself I added a file to paths.d directory for my android stuff (the sudo command will only work if you have those privileges on your mac):

  • sudo sh -c ‘echo “/Users/me/Android/sdk/tools” >> /etc/paths.d/android_paths
  • sudo sh -c ‘echo “/Users/me/Android/sdk/platform-tools” >> /etc/paths.d/android_paths’
    • Note/Reminder “>>” appends to the existing file use “>” to create a new file

Then I ran ls -l /etc/paths.d to verify the file was there:

Me:platform-tools me$ ls -l /etc/paths.d/
total 8
-rw-r–r–  1 root  wheel  75 Dec 1o 11:44 android_paths

To “refresh” your terminal to start working with the new path once you updated it:

  • . /etc/profile