Editor’s note: below is a blog post from Justin Jasmann, Android Application Development Consultant. Follow him on Twitter at JustinJasmann.
Imagine this: You’ve got your Android app running well on BlackBerry 10 (that’s awesome by the way), but there’s a small piece that’s not working quite right. How exactly do you go about diagnosing the problem?
As James Dreher pointed out in his post about the 2.0 Command-Line Tools, you can connect your BlackBerry device to whichever IDE you’re most comfortable with. In order to gain access to the LogCat information from there, you can simply debug the Android project, as you would during normal development.
Now I know what you’re thinking: “What if you no longer have the project source?” That’s what I’m here to show you. Today, we’re going to pull the Android logs from your BlackBerry device directly.
There are a few things that you’ll need before we start, so make sure you have these ready:
- Android SDK
- Command-Line Tools v2.0
- An SSH public-key which will represent the host computer that you’re connecting your device to
Note: The easiest way to get a public key created for you is to use Momentics to setup an SSH connection. The rest of the tutorial will use a key that was created for the device via Momentics.
Also note: If you’re having problems creating a public key, you can follow this tutorial.
Let’s get started!
- Establish a secure connection to your device using blackberry-connect
- With blackberry-connect running, open a new terminal or command-prompt
- Navigate to the platform-tools directory of your Android SDK. We will be using the adb utility that’s included with the SDK.
- Connect to the Android Runtime on BlackBerry 10 using
1adb connect 169.254.0.1
- If you want to output the current contents of the log buffer to a file, use:
1adb logcat –d > logfile.log
- If you’d rather watch the logs live, you can use:
And that’s it! Simple, right? Let us know if you have any questions in the comments below!