KitchenSink on the Kindle Fire

With the popularity of the Kindle Fire, I thought it might be interesting to see how I could use Appcelerator’s Titanium to develop for this new device.

The Fire is based off a heavily modified version of Android 2.3.3 so it was pretty easy to get my first app up and running.

Using the Titanium Sample app, KitchenSink, I’ve outlined below how you can get your Titanium development environment setup and your apps running on the Kindle Fire.

Getting the Kindle Ready

Just like most Android devices you need to allow for the installation of apps from unknown sources.

  1. Open the options menu
  2. Select More…
  3. Select the “Device” option  
    Device menu
  4. Toggle the “Allow Installation of Applications From Unknown Sources” to OnAllow Installation of Applications

We are now ready to be able to deploy our own apps.

Setup our USB connection

So that our computer can see the Kindle when it is connected via USB we’ll have to make a small update to the adb_usb.ini file.

  1. Navigate to ~/.android and open the adb_usb.ini file your favorite text editor
  2. Type 0X1949 at the end of the file, then save and close adb_usb.ini.
  3. Stop ADB server with the adb kill-server command, then use the adb devices command. You should see the Kindle Fire listed.

For more details please see this article by Technipages.

Setting up our development environment

Next is setting up our development environment. 

I am using the following Titanium components:

  1. The latest version of KitchenSink from Github
  2. Titanium Mobile SDK 1.8.0.1 using V8 Runtime
  3. Titanium Studio version 1.0.7.201112152014

After importing the KitchenSink into my Workspace it is time to setup the Android emulator to better reflect the Kindle Fire’s specs.

To download any of the above mentioned components please visit here for how to get started.

Updating KitchenSink

The Kindle Fire isn’t a Google Approved build of Android. This means that we don’t have access to a few of the native APIs such as Maps. To handle this, we need to make a few adjustments to the KitchenSink demo.

  • Remove the map api keys from the tiapp.xml file
  • Remove any of the fields that have references to mapViews.

All of the files that contain references to the MapView are in the Examples folder.

Remove the following:

  1. add_show_views.js
  2. mixing_views_1.js
  3. map_view1.js
  4. map_view2.js

This will allow you to push to device without any issues. Make sure you update the views.js to remove any references to the files you deleted, or you might tap on a link that doesn’t exist any longer.

Creating the Emulator

Titanium Studio manages the linkage between the Android AVD images and your projects for you.  It doesn’t seem as though there is an option for you to specify which AVD image you would like to use.

The best work around seems to be doing the following:

  1. When in the KitchenSink project go to Debug Configurations under the Run menu
  2. Select the 2.3.3 for your Android API level and a Screen Size that you usually do not use. I recommend using WVGA854 since this is an easy starting place.

    Debug Configuration Menu

  3. Then press Apply, then Debug
  4. This will launch the emulator, wait until you see the KitchenSink app open in the emulator. This means the AVD has fully been created.
  5. Now close the Android Emulator
  6. Open the Android AVD Manager. You can do this by going into your Android / Tools folder and issuing the below terminal command

    avd

  7. This will load the Android AVD Manager as shown below.AVD Manager
  8. Select the AVD Image we just created in Titanium Studio and press the Edit button.
  9. We now can start to update the AVD to have the same specs as the Kindle Fire. You will want to adjust the resolution to be 600 x 1024, turn off GPS support, change the LCD density to 160, and increase the RAM to 512.  You will also want to remove Camera support.

    AVD Properties

  10. When finished press the “Edit AVD” button to save your changes.
  11. Go back into Titanium Studio and Run the KitchenSink project again in Debug. Your emulator should now look like the below.

    KS Running in Kindle Fire Emulator

  12. Your now ready to test in the emulator and when ready push to device.

Pushing to Device

This is the easy part.  Simply connect your Kindle Fire via USB and it your computer a couple of seconds to identify your device. 

Before starting the deployment process from within Titanium Studio I recommend updating the tiapp.xml file. You can simply add/remove a space at the end of the file.  This will force Titanium to perform a full build during the deployment process.

To start the deployment process, select the Deploy to Device option on your project menu as shown below.

Deploy to device

The terminal window in Titanium Studio will indicate when it has connected to your Kindle Fire and will automatically start the build process.  Sometimes there is a connection problem and the deployment process cannot find your device.  This usually can be fixed by unplugging the USB cable connecting your device, then plugging it back into your computer.  You might need to restart the deployment process again.

Does it work on the device?

The simple answer is yes.  There are a few things that don’t work due to hardware or software limitations.  The Kindle Fire’s theme works well with the Titanium native controls providing a new look and feel considering the app was never designed for this platform.

Overall  the KitchenSink works very well on the Kindle Fire.  Scrolling, page loads, and general navigation are faster then my Nexus S ( not running the V8 runtime ).

What does it look like?

Using Android Screencast I’ve put together a short walk thru of the Kindle Fire running KitchenSink.

 

What doesn’t work?

There are a few things that don’t seem to be working on the device.

  1. MapView – We already talked about this, but the MapView doesn’t work as this is a forked version of Android
  2. Geo Location – The Titanium.Geolocation.getCurrentPosition method returns “no providers are available”.  I guess this is expected as the Kindle Fire doesn’t provide GPS support. Even if you use setPreferredProvider=”network” you will receive the “no providers” error. Seems like Amazon completely removed the geo stack.
  3. Camera– There is no camera on the Fire so it goes without saying any feature that requires this will not work.  The Titanium framework gives you a method to check if a camera is available. If you use this, you wont have any issues.

Closing comments

Other then the obvious screen size differences and lack of mapView support using Titanium on the Kindle Fire doesn’t appear to be any different then building for the Android Phone platforms.

One thing is clear, just as with iPad apps, you will want to design a different user experience for the Kindle Fire.  The Kindle’s bottom navigator and darkened theme will most likely have a large impact on your overall app design.

I look forward to experimenting with this new form factor as it is smaller then an iPad but bigger then a phone.

I continue to be impressed with how easy and quickly you can get an app running using Titanium.  The fact it only took removing a few files to get the KitchenSink API example app up and running is another example of the flexibility and durability of the Titanium platform.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s