At Google IO 2011, there was fascinating talk about how to connect an Android application to a shared database. It was called “Android + App Engine: A Developer’s Dream Combination“. The demo itself goes by the name “CloudTasks”. Like many things from Google, the source code is available for us to study and start our own projects.
When you import the source code for the CloudTasks demo program, there is a problem with running it in the Android emulator and connecting to your own local Google App Engine application. For projects of this type, there should be an item on the Eclipse “Run – Debug As” menu that allows you to run and debug a “local app engine connected Android application”. That menu item is missing. Here’s what you do to fix the problem.
My guess is that the source code available for download from the Google Code Cloudtasks page was created with an earlier version of the Google plugin for Android. So you have to do the following steps:
1. Use Eclipse’s Import command to import the two projects: CloudTasks-Android, CloudTasks-AppEngine.
2. Locate and edit the “.project” file for the CloudTasks-Android project,
3. Find the last line in the section of the file that begins with <natures>.
4. Change the <nature> element that indicates the type of the project.
Change
com.google.gdt.eclipse.mobile.android.cloudConnectedNature
to
com.google.gdt.eclipse.appengine.rpc.appengineConnectedNature
As soon as you do that, the Debug As item appears. Then you are ready to see if it all works.
Here’s my short version of the instructions. The best explanations are in the resources I link to below.
- Start the app by selecting “Debug As” for the item “App Engine Connected Android Application”.
- Inside the running Android app, bring up the menu for app. Choose which Google Account you want to use.
If you do not have a Google account set up in your emulator — and you probably do not — set one up. (If you do not see the option to set up an account, change your virtual device so it runs using Google APIs 2.2 or later.) - Run the App Engine application in your web browser. When prompted for a user name, use the same name you just set up in the Android app.
- Add a task in the web application, just to see that it is working.
- Go back to the Android App and see if the tasks shows up. If it does, great.
You now know that you are connected to the same database as the web application. - Touch the “+” button in Android app so you can add a task from there.
As you hit save, keep you eye on the web application. It should update within a second or two.
At this point, you should be able to add items to the to-do list, in either the web application or the Android app. No matter where you are, any changes you make are propagated to the other one.
Additonal Information
Here are the resources related to CloudsTasks that I have found useful.
The best place to start, in my opinion, is the video from the Google I/O 2011 conference. The title alone gets your attention: “Android + App Engine: A Developer’s Dream Combination”. It’s one hour long so you have to wait a bit before you see why it really might be a dream combination. At some point, start at the beginning of the video and watch the whole thing. However, if you want to skip ahead to the conclusion, here’s a link into the video, about 44 minutes in, that shows the finished demo: Android + App Engine: A Developer’s Dream Combinition at 46:36.
References:
- Blog article from Brad Abrams. – These are the best notes about the demo program, how to use it, and how to get started with your own project. There are two demo programs mentioned early on in the article: CloudTasks and BigDaddy. I suggest trying both of them.
- App Engine Connected Android Application – This provides a good summary of what the architecture is behind the demo.
With the newer versions of the Google plugin for Eclipse, you can easily create projects like those in the demo. - Android Cloud To Device Messaging Framework – This is a detailed description of C2DM, which is the service that helps you keep your Android app in sync with changes made in your server-side database.



Recent Comments