Announcing App Engine 1.4.3. Release

Just in time for spring, we have a new App Engine release to bring our Java and Python runtimes even closer to parity. For Python, we’ve launched a test library to match the existing Java testing framework, and for Java we’ve introduced the Deferred and Remote APIs. This release also introduces a new Blobstore writing feature, the experimental release of the Prospective Search API in Python, and a few goodies for Task Queue and Cron users.

Python

  • Prospective Search API: The experimental Prospective Search API allows Python runtime users to detect and take action on datastore entities that match certain criteria when they are written. For the experimental release, users will be allowed 10,000 subscriptions with the Prospective Search API. Pricing will be announced once the feature is fully launched.
  • Testbed Unit Test Framework: The Testbed suite for Python provides an easy interface for using App Engine API stubs in integration tests similar to the previously existing Java Testing Framework. You can create tests for your application that do not rely on calling App Engine production services, which speeds up the time your tests take to complete, and eliminates dependencies for your test on external services. Here at Google, we’re well known for our testing culture, and we hope that this API will allow you to develop more stable code more quickly.

Java

  • Concurrent Requests: Until now, Java applications relied on starting additional instances to dynamically scale up for higher traffic levels. Now with support for concurrent requests, each application instance may serve multiple user requests at the same time. To start, ensure your application’s code is threadsafe, then enable concurrent requests by adding the flag to your appengine-web.xml.
  • Java Remote API and Deferred API support: The Remote API and Deferred API libraries have been supported in Python for awhile, and now they can be used with Java, too! The Remote API allows you to perform operations on your application’s datastore from your local machine. This is particularly useful for work that is not well-suited to App Engine’s request/response model. The Deferred API allows users to more easily write and execute ad hoc tasks. Our docs contain more information and examples on how to use the Remote API and Deferred API in Java App Engine.

New and changed APIs

  • Files API: The new Files API in Python and Java allow you to pragmatically read and write data using Blobstore. This API can be used to generate reports, export data, or do anything that your heart desires that requires large, binary objects.

Serving Changes

  • Task Queue and Cron update: We’ve addressed some of your top requested items for Task Queues and Cron. With this release, you can now configure the specific application version to which a task queue or cron job will send requests. For those wanting to schedule cron jobs with a range syntax like “every 5 minutes from 11:00 to 17:00”, that too is available in the 1.4.3 release. Last, but not least, the Admin Console Task Queues page now displays a more accurate estimate of queue size for queues containing more than 2000 tasks.

Coming soon

Finally, we have a pre-announcement about the 1.4.4 release. In 1.4.0, we introduced a feature that allowed users to download code that they’ve deployed to App Engine. In 1.4.2 we released admin roles allowing for Owners. When 1.4.4 is released, we plan on including a change that allows both the person who uploaded the code to download it, as well as the Owner(s) of the project (as listed in the Admin Console). In preparation for this, be sure to properly assign roles to all developers on your App Engine application in the Admin Console. Alternatively, you will still be able to permanently disable the code download feature for your application.

That’s it for now, for additional information read the full release notes, including all new features and issues fixed for Java and Python. All feedback is welcome and encouraged in our groups.

Android: Identifying App Installations

In the Android group, from time to time we hear complaints from developers about problems they’re having coming up with reliable, stable, unique device identifiers. This worries us, because we think that tracking such identifiers isn’t a good idea, and that there are better ways to achieve developers’ goals.

Tracking Installations

It is very common, and perfectly reasonable, for a developer to want to track individual installations of their apps. It sounds plausible just to call TelephonyManager.getDeviceId() and use that value to identify the installation. There are problems with this: First, it doesn’t work reliably (see below). Second, when it does work, that value survives device wipes (“Factory resets”) and thus you could end up making a nasty mistake when one of your customers wipes their device and passes it on to another person.

To track installations, you could for example use a UUID as an identifier, and simply create a new one the first time an app runs after installation. Here is a sketch of a class named “Installation” with one static method Installation.id(Context context). You could imagine writing more installation-specific data into the INSTALLATION file.

[php] public class Installation {
private static String sID = null;
private static final String INSTALLATION = "INSTALLATION";

public synchronized static String id(Context context) {
if (sID == null) {
File installation = new File(context.getFilesDir(), INSTALLATION);
try {
if (!installation.exists())
writeInstallationFile(installation);
sID = readInstallationFile(installation);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return sID;
}

private static String readInstallationFile(File installation) throws IOException {
RandomAccessFile f = new RandomAccessFile(installation, "r");
byte[] bytes = new byte[(int) f.length()];
f.readFully(bytes);
f.close();
return new String(bytes);
}

private static void writeInstallationFile(File installation) throws IOException {
FileOutputStream out = new FileOutputStream(installation);
String id = UUID.randomUUID().toString();
out.write(id.getBytes());
out.close();
}
}[/php]

Identifying Devices

Suppose you feel that for the needs of your application, you need an actual hardware device identifier. This turns out to be a tricky problem.

In the past, when every Android device was a phone, things were simpler: TelephonyManager.getDeviceId() is required to return (depending on the network technology) the IMEI, MEID, or ESN of the phone, which is unique to that piece of hardware.

However, there are problems with this approach:

Non-phones: Wifi-only devices or music players that don’t have telephony hardware just don’t have this kind of unique identifier.
Persistence: On devices which do have this, it persists across device data wipes and factory resets. It’s not clear at all if, in this situation, your app should regard this as the same device.
Privilege:It requires READ_PHONE_STATE permission, which is irritating if you don’t otherwise use or need telephony.
Bugs: We have seen a few instances of production phones for which the implementation is buggy and returns garbage, for example zeros or asterisks.
Mac Address

It may be possible to retrieve a Mac address from a device’s WiFi or Bluetooth hardware. We do not recommend using this as a unique identifier. To start with, not all devices have WiFi. Also, if the WiFi is not turned on, the hardware may not report the Mac address.

Serial Number

Since Android 2.3 (“Gingerbread”) this is available via android.os.Build.SERIAL. Devices without telephony are required to report a unique device ID here; some phones may do so also.

ANDROID_ID

More specifically, Settings.Secure.ANDROID_ID. This is a 64-bit quantity that is generated and stored when the device first boots. It is reset when the device is wiped.

ANDROID_ID seems a good choice for a unique device identifier. There are downsides: First, it is not 100% reliable on releases of Android prior to 2.2 (“Froyo”). Also, there has been at least one widely-observed bug in a popular handset from a major manufacturer, where every instance has the same ANDROID_ID.

Conclusion

For the vast majority of applications, the requirement is to identify a particular installation, not a physical device. Fortunately, doing so is straightforward.

There are many good reasons for avoiding the attempt to identify a particular device. For those who want to try, the best approach is probably the use of ANDROID_ID on anything reasonably modern, with some fallback heuristics for legacy devices.

Top Ten Reasons to use Google Plugin for Eclipse

As I speak at JUGs and conferences around the world, I’m often surprised that some folks have never seen some of the best features of Google Plugin for Eclipse, such as using the Eclipse debugger with a GWT app. So in no particular order, here are 10 reasons you should use Google Plugin for Eclipse (GPE).

  1. GWT+GAE made easy. GPE is the easiest way to get started with GWT and Google App Engine (GAE). Just check the SDKs box when you install the plugin through the Eclipse update site. It’s easy to upgrade the SDKs this way (Help | Check for updates), and a status bar message in Eclipse will remind you when new versions are available.
  2. Wizards. It’s easy to create your first GWT+GAE project. Click File | New | Web application project and you’ll get a sample app that you can run locally to kick the tires and then deploy to Google App Engine. Beyond creating a new project, there are wizards to create new UiBinder templates, ClientBundles, GWT modules, and entry points. To use the wizards, click File | New and look for the items with the GWT toolbox logo (or click File | New | Other… and browse to the Google Web Toolkit folder).
  3. GWT Designer, now bundled with GPE, lets you quickly create a GUI. To see it in action, create a class that extends GWT’s Composite class, then right-click on the file and Open With | GWT Designer. When the editor opens, click on the Design tab at the bottom. After GWT Designer launches, click a tool on the palette (say, LayoutPanel), then click on the empty design window to drop the widget in place. Click the source tab to see the code that GWT Designer wrote for you. It’s a great way to learn the new cell widgets like CellTable and TextColumn, and GWT Designer has a built-in WYSIWYG CSS editor, too.
  4. Quick fixes and warnings help you write good GWT code quickly. For example, when you create an interface that extends GWT’s RemoteService class, GPE will prompt you to create the corresponding async interface required for GWT-RPC. Just click Ctrl+1 (Quick Fix) on the red squiggly and away you go.
  5. Dev mode integration lets you test your code quickly. Run As | Web Application starts GWT development mode and the App Engine dev server (if applicable) so you can test your code in the browser. When dev mode starts, look for the Development Mode tab in Eclipse and double-click the URL to launch your app in the default browser. With GWT dev mode running, you can make changes to your Java code, hit Refresh in the browser, and see your changes live.
  6. Debugging in dev mode rocks. Set a breakpoint in Eclipse, right-click on your project, and Debug As | Web Application. Switch to the browser and run your code. Eclipse will open the Debug perspective where you can step through your code line-by-line, inspect variables, etc.
  7. One-click deploy to Google App Engine. Just click the Google App Engine logo on the toolbar.
  8. Maven support. GPE works with Maven projects via m2eclipse (see setup instructions). Check out a Maven project like the Expenses GWT+GAE sample app into your workspace, then click File | Import | Existing maven project and point it to the pom.xml file. Maven will download all the jars and plugins required in the POM, and GPE will configure the project with the GWT and/or App Engine SDKs from the POM. You can then run Maven commands externally or Run As | Web Application in Eclipse.
  9. Testing. Run As | GWT JUnit Test lets you easily run test cases that extend GWTTestCase.
  10. SpeedTracer. You can launch SpeedTracer from within Eclipse. Click the green stopwatch icon on the GPE toolbar. GPE will compile your app, run it, and launch SpeedTracer in Chrome to profile your app.

Haven’t tried it yet? Install Google Plugin for Eclipse now.