Clone this wiki locally
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
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
.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.
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: