Skip to content
swistak35 edited this page Sep 15, 2011 · 4 revisions

Solutions to common problems

I do something that tries to communicate to a device (either a phone or an emulator) and get "error: device offine" or "waiting for device"

The android SDK (in particular, adb sometimes has some issues, especially when you restart emulators. Running

$ adb kill-server; adb start-server

at a shell should fix it. You may have to try the command you want to run 2 or 3 times, especially if you're impatient, because the first one will make the server start again, but it may not finish in time for the first command to work.

I tried to install an apk on my device using adb and got Failure [INSTALL_FAILED_DEXOPT]

The app probably doesn’t have enough space to install. See this for details. Delete some stuff, uninstall other apps, etc. If it's an emulator, sometimes the easiest approach is to just delete it and build a fresh emulator image.

I don't know why my app's not working

Check out the logs. You can run

$ adb logcat

to see Android's log messages. If you have several devices connected, you may need a parameter to tell it which device you want the logs of. adb logcat --help explains that.

The logs are high volume but useful. If your Ruby script is crashing, you should see the error and a backtrace. You can also log from your script, like so:

Log.v "TAG", "message"

That's just a Ruby call, so you can have the message be any Ruby expression that returns a String. (Obviously, you can call .to_s or .inspect to make a non-string into a string.)

The tag is just meant to identify what kind of message it is. It doesn't really matter what you put, but making it all caps is useful for having it stick out.

I get an error "org.apache.tools.ant.BuildException: Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath.

To fix this problem I had to manually specify the JAVA_HOME and CLASSPATH.

export JAVA_HOME=/usr/lib/jvm/java-6-sun

export CLASSPATH=${JAVA_HOME}/lib/tools.jar

I get an error "command not found: adb" when I'm trying to run "adb"

To fix this problem, you should add the sdk/platform-tools to your PATH. Try:

export PATH=$PATH:/home/USER/android-sdk-linux_x86/tools/:/home/USER/android-sdk-linux_x86/platform-tools

Instead of:

export PATH=$PATH:/home/USER/android-sdk-linux_x86/tools/

Clone this wiki locally