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

Build Instructions (v2.0.2 and lower)

Sean Barbeau edited this page Feb 6, 2014 · 3 revisions

These instructions are for OTP Android v2.0.2 and lower, which used Maven and Eclipse for building and an IDE. Check out the main Developer's Guide to build the newest version of the project, which uses Gradle and Android Studio.

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 Android Plugin for Eclipse. Libraries and dependencies are managed using [Maven] (http://eclipse.org/m2e/). Note that you'll need to install the m2e Android Maven plugin in Eclipse.

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.

Then, in Eclipse do "File->Import->Maven->Existing Maven Projects", and point to the directory where you cloned the repo.

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.

Last step is to import the "Google Play Services" library project, which is also included in the Git repository:

  1. In Eclipse, go to File->Import->Existing Android Code Into Workspace.
  2. Browse to the google-play-services_lib subdirectory in the project, and click Finish
  3. Double-check that the OpenTripPlannerAndroid has this project listed as a library project by right-clicking on project, then Properties, then click on Android category in the left column. If google-play-services_lib isn't listed as a library, click on Add... and add it.

Finally, use the normal Eclipse "Clean and build" process. Build the google-play-services_lib project first, and then the main OpenTripPlannerAndroid project.

Then, run the Android project on your device or an Android emulator (emulator should be at least Android 4.2.2 to work with Play Services).

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.

Testing the app with your own OTP Server

Due to compatibility issues trying to simultaneously support older versions of the OTP REST API (v0.7.X) simultaneously with newer versions, we suggest that OTP server versions be v0.9.1 or higher to work with the OTP Android app. In OTP v0.9.0 and higher, you can check your OTP server version number using the serverInfo REST API method.

For example: http://rtp.trimet.org/opentripplanner-api-webapp/ws/serverinfo

…which gives a result such as:

<serverInfo>
<serverVersion>
<version>0.9.1-SNAPSHOT</version>
<major>0</major>
<minor>9</minor>
<incremental>1</incremental>
<qualifier>SNAPSHOT</qualifier>
<commit>de91d05ef4bff7d22ef0b3bec8991625b3b2c797</commit>
</serverVersion>
<cpuName>Intel(R) Xeon(R) CPU X5660 @ 2.80GHz</cpuName>
<nCores>24</nCores>
</serverInfo>

In OTP v0.8.0 and lower, this REST API method doesn't exist.

To get started testing your OTP Server with the Android app, we suggest entering your OTP Server root REST API URL directly into the OTP Android app (see the OTP Server Directory (a Google Docs spreadsheet) for example root REST API URLs). To do this, go to the "Settings" menu in the app and uncheck "Auto Detect OTP Server". Then click on "Custom Server URL", and enter the root URL for your OTP REST API (e.g., http://opentripplanner.usf.edu/opentripplanner-api-webapp/ws). Plan a few trips to verify that you see a path on the screen from the origin to destination, and that if you tap on the small "directions" icon in the lower-left corner of the screen you see a list of written directions.

Once you've confirmed that this works, then we can add your OTP server to the OTP Server Directory to make it available to regular users of the app. See the first page of the OTP Server Directory for instructions on adding your OTP Server.

Once your OTP Server is added to the directory, it may take a few minutes to be available in the app.

When starting the app, OTP Android should try to auto-detect the server if your phone is within based on the "Bounds" field in the directory. If auto-detection doesn't work, you can manually select server. To force manual server selection, go to "Settings" and uncheck "Auto Detect OTP Server". Then, click on "Refresh server list" and it should take you back to the main screen and ask you to pick from the server list. If your server doesn't appear, try waiting a few minutes for the Google Docs spreadsheet to update and try again.

Try planning a few trips from/to locations that are known to work in your normal OTP web UI, and ensure that the app works with your server. If your server doesn't work with the app, we will have to remove the app from the directory until we can confirm it works.

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 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.

If you get a bunch of compilation issues, be sure you have the google-play-services_lib project imported and open in Eclipse (see above "Building and Running..." instructions). Also double-check that the project is targeting Android 4.3 SDK tools (Properties->Android->Project Build Target), which also means you need to install this platform as part of your Android SDK. Sometimes Eclipse imports a project and changes this Project Build Target to a lower Android version, which then causes Eclipse to show build errors.

If you want to quickly test OTP server request/responses from an Android client, you might want to check out our "OTP Java Client Test" project. We developed this to help save development time during the iterative API testing process, as on start-up it automatically send a request to a hard-coded REST URL and immediately gives a response if it was successful. This saves time over doing the same testing process manually in the main OTP for Android app.

Mailing List - OpenTripPlanner Developer list - Just be sure to mention "OTP Android" in the subject line.