Getting Connectbot working on Kindle Fire

Ever since getting the Kindle Fire I’ve been dreaming of the day that I can get ConnectBot working.  The first hurdle is that this is not available in the Amazon market.  Luckily, being under the Apache License they did have code available on the google code site.

After installing the apk file, i started up a test connection.  Everything was going well until I got to the part where I enter the server name.  The virtual keyboard pops up, but instead of an enter key there is only .com.  I recognized this as the keyboard that comes up when you are in the web browser.  Unfortunately, unlike the web browser, there is no additional “go” button.

First thing I did was check the issues to see if this has been reported yet.  Yes it had, sounds like many people are itching to ssh from their Kindle Fire :-)

So I dutifully tagged the issue and waited for a fix…

After waiting a few days I couldn’t let it sit. I needed to dig in myself and see if i could find anything.  Seemed like a relatively easy problem

The Process

First I grabbed the code via git from their project page and setup my Android dev environment.  This included installing the Android SDK, installing JDK and installing Eclipse.

Once I got all my goodies installed I connected the Kindle Fire, waited for the “connecting USB” to finish…and…NOTHING!

After a little research I learned I first needed to install the Google USB drivers for this device.  Went into device manager and found the Kindle device with missing drivers, right-clicked and pointed to the ini file.

At this point I was able to do an adb devices and could verify that my Kindle Fire was detected

At this point I was still pretty much at a loss of where to being.  I knew just from playing around with the Kindle Fire that there definitely is a keyboard layout that had an enter key.  For some reason this layout was not using it though, it was defaulting to the same one used for entering websites.  Having the .com where enter should be is normally not a problem - when the keyboard collapses you can then click on the go button.  In this case, however, the keyboard does not allow for that option.

After doing some research I learned that there are many different inputType fields that will basically determine what keyboard layout was used.  Getting closer…

What I finally stumbled upon was, oddly, the default text in the input field “[email protected]:port”.  I was able to use this very unique string to search through the code to eventually come upon my first clue. I was lead to a “hint” (literally) in the __ element, inside of which I noticed the _android:inputType_ that was initially set to_ textEmailAddress_, I changed this to _textMultiLine_.  My theory being that if it had multiple lines there was some way to send a carriage return.

So far success…

Except now I get to the password line and I’m facing a “new” keyboard with the same issue: a .com where and enter should be.

So doing some more searching I use my same method of searching for the text hint, this time Password: Pretty quickly I found this one but it wasn’t quite the same.  I was lead to strings.xml which is essentially a “lookup table” for strings.  At least now I know that Password: _will be in the code somewhere as _prompt_password.  So digging some more I found a corresponding _.  _But this lead me to a field for key generation (probably needs to be "fixed" for everything to actually work).  This wasn't quite what I was looking for.

Browsing the “layout” folder, I was eventually able to find the file I needed. I found a console_password line in act_console.xml.  After adding a android:inputType=”textMultiLine” I was set.  I ran the file, sending it to my Fire and met with success this time when connecting to my server.  Using the following method I was able to take a screenshot of my victory.

The changes

The results

I still have little understanding of why what I changed did what it did, or what repercussions this might have on other Android platforms. I hope this does show, however, that with a little persistence to “scratch an itch” it is pretty easy to use some really basic research and techniques to modify Android source code to meet your needs.

Since this has sparked in interest in me for learning more about Android development.  I look forward to learning more about the ins and outs of the platform and how to properly submit and implement patches for bugs like this.

Since this was a quick and dirty hack, I look forward to input on the right way to do this.

Edit 2011-11-22: I forgot to actually describe the problem (lack of Enter key)…