Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.

Developer Guide

barbeau edited this page Nov 9, 2012 · 41 revisions

This page contains instructions for configuring and building the OpenTripPlanner Android app from the source code.

Components

Before diving into the source, its helpful to understand the different pieces that help the OTP Android app to function. Here's a list of some components that are used in the functionality of the OTP for Android app:

  • OSM Droid - Used for the map tiles and map overlays.
  • OTP POJOs project - Defines the objects that are used in the deserialization of REST API responses from the OTP server. We use Jackson JSON Processor to deserialize JSON responses from the server.
  • OTP Server Directory (a Google Docs spreadsheet) - maintains the centralized list of OTP Server deployments and their coverage areas, so the app knows which OTP server it should communicate with to plan trips based on the user's location.
  • Google Places API - Used for point-of-interest search. Provides rich results based on Google's database for areas such as the U.S. Requires a developer key (see Customization section below).
  • Nominatim - Also used for point-of-interest search. Provides results for points-of-interest that are recorded in OpenStreetMap, which may provide more information than Google Places API for international locations (depending on the quality of Google Maps in the area).

JAR files for all of these libraries are included in the libs folder of the OTP for Android project.

Getting Started

First, you'll need a JDK installed. We recommend JDK 1.6.

Next, we suggest you use Eclipse for an IDE (The "EE" version is suggested). You'll also need the Android SDK, and finally the Eclipse Android plugins. Follow the instructions at the above linked pages to set up Eclipse and the Android SDK and plugin.

Getting the code

The OTP Android app code is versioned using Git, so you can use your favorite Git client or the Eclipse Git Plugin "EGit" to clone the OTP Android repository

Here's our Github repo:

https://github.com/CUTR-at-USF/OpenTripPlanner-for-Android.git

If you plan on submitting improvements, we suggest you fork our project (instead of cloning our repo directly) and work off of your forked repo so you can commit to your own OTP Android repository and use Github's Pull Request feature to submit improvements for our review.

Building and running the project

You'll need your own Google Places API key to point-of-interest search. Follow the "Setting up your own Google Places API key" directions in the next section to set up your key.

After you've set up your Google Places API key, use the normal Eclipse "Clean and build" process. Then, run the Android project on your device or an Android emulator. Yup, its that easy!

Customization

Setting up your own Google Places API key

To use the Google Places API, you need a developer key. This key should be your own private key, so by default we don't include a key in the repository.

To add your own key, create a text file “res/raw/googleplaceskey.txt” in the Android project that contains only your developer key in plain text. The app will check for this key file when using the Google Places API, and if the key exists the app will use it.

Updating the mobile REST API interface

We separate the Plain Old Java Objects (POJOs) used in the deserialization of the REST API responses into a different project. Check out the opentripplanner-pojos-unversioned project for more information about the mobile REST API code.

Troubleshooting

If you hit a compilation problem in Eclipse, we recommend cleaning your application, then shutting down Eclipse. Restart Eclipse, and then build the project. This solves most issues.

Clone this wiki locally