Posts

Showing posts from April, 2012

Using a local MySQL instance for developing on Google Cloud SQL

This keeps giving me trouble, but I think I have it figured out now. Most of the cloud sql docs assume that you will be running your development on a cloud instance along with your production/test. This does not work for me due to the latency associated with the remote dbs, so I go for the local dev option. However in order to get this to work you have to put a copy of the mysql jdbc driver into this folder in your sdk: eclipse\plugins\com.google.appengine.eclipse.sdkbundle_1.6.4.v201203300216r37\appengine-java-sdk-1.6.4\lib\impl (obviously your exact folder will vary depending on your sdk bundle version) Whenever you upgrade your SDK you will need to copy the mysql connector jar to the new impl directory. The latest upgrade to the SDK (1.65) appears to have been a bit panicked. It was released on the evening of the 1.64 release. Oops. There was no eclipse plugin for 1.65. I made the mistake of upgrading the standalone version of the SDK (which I don't in fact use) and copy

Running emulator and phone simultaneously

When I am developing I often have the need to run something on the phone and the emulator. Due to the long startup time on the emulator I don't want to shut this down whenever I connect the phone. My preferred way to view logs is using a bash shell with the adb logcat command. This however will not produce the desired output when the 2 platforms are running together. Instead the -s for serial number switch must be provided. The format is adb -s emulator-5554 logcat I had previously tried adb logcat -s emulator-5554 which does not work. The adb program gets the logcat param before it sees the switch and you just get a normal log tail. This is a trivial post, but is very handy now that I have figured this out :) To get the list of devices (ie. your phone and emulator serial numbers in this case) enter adb devices at the command prompt.

Dealing with the Same Origin Policy when developing AJAX based JQueryMobile apps

The title of this post is quite a mouthful, but this was a tricky problem to fix and I wanted to share it here. Basically I am developing a mobile app using html, css and JavaScript. The app uses ajax to retrieve its data from the backend server (Google Cloud SQL). This does not present a problem when I am running the app as a packaged apk (which just contains web technologies and a single Activity to bootstrap the whole thing). However when I am in development mode on my desktop I get all the advantages that a decent browser has to offer a developer - inspection, view the DOM etc. Can't reasonably develop without this stuff. The difficulty arises when I try to run the phone app on Chrome. The JavaScript security in the shape of the Same Origin Policy prevents the ajax from running. To get around this you need to set a response header on your backend server - the one that runs your servlet. This looks like this: res.setHeader("Access-Control-Allow-Origin", "*"