Skip to content

Commit

Permalink
Upgrade core infrastructure to fix unit tests/stay on top of Play Sto…
Browse files Browse the repository at this point in the history
…re requirements

* Update to Gradle 8
* Remove support for Amazon Fire (we hadn't published a new build for it in several years, and I cannot in good conscience carry forward a dependency I can't test)
* Update minSdkVersion to 21 and targetSdkVersion/compileSdk to 33
* Fix unit tests/comment out one that either needs some more TLC or total elimination
* Update built-in `regions_v3.json` file
  • Loading branch information
aaronbrethorst committed Dec 17, 2023
1 parent eb327d6 commit eca3888
Show file tree
Hide file tree
Showing 35 changed files with 311 additions and 5,041 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ If you can, please submit a pull request with the fix or improvements including
1. Fork the project on GitHub
2. Create a feature branch
3. Write tests and code
4. Run the unit tests with `gradlew connectedObaGoogleDebugAndroidTest connectedObaAmazonDebugAndroidTest` to make sure you didn't break anything
4. Run the unit tests with `gradlew connectedObaGoogleDebugAndroidTest` to make sure you didn't break anything
5. Apply the `AndroidStyle.xml` style template to your code in Android Studio.
6. If you have multiple commits please combine them into one commit by squashing them. See [this article](http://eli.thegreenplace.net/2014/02/19/squashing-github-pull-requests-into-a-single-commit) and [this Git documentation](http://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) for instructions.
7. Push the commit to your fork
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Please make sure these boxes are checked before submitting your pull request - t

- [ ] Apply the `AndroidStyle.xml` style template to your code in Android Studio.

- [ ] Run the unit tests with `gradlew connectedObaGoogleDebugAndroidTest connectedObaAmazonDebugAndroidTest` to make sure you didn't break anything
- [ ] Run the unit tests with `gradlew connectedObaGoogleDebugAndroidTest` to make sure you didn't break anything

- [ ] If you have multiple commits please combine them into one commit by squashing them for the initial submission of the pull request. When addressing comments on a pull request, please push a new commit per comment when possible (reviewers will squash and merge using GitHub merge tool)
Binary file not shown.

This file was deleted.

This file was deleted.

31 changes: 11 additions & 20 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

We use [Gradle build flavors](http://developer.android.com/tools/building/configuring-gradle.html#workBuildVariants) to enable a number of different build variants of OneBusAway Android.

We have two Gradle "platform" flavor dimensions:
We have one Gradle "platform" flavor dimension:

* **google** = Normal Google Play release
* **amazon** = Amazon Fire Phone release

...and three Gradle "brand" flavor dimensions:

* **oba** = Original OneBusAway brand
* **agencyX** = A sample rebranded version of OneBusAway for a fictitious "Agency X"
* **agencyY** = A sample rebranded version of OneBusAway for a fictitious "Agency Y"

This results in a total of 2 * 3 = 6 core build variants. Each of these core variants also has a debug/release build type - the end result is that you'll have 12 build variants to choose to build.
This results in a total of 1 * 3 = 3 core build variants. Each of these core variants also has a debug/release build type - the end result is that you'll have 6 build variants to choose to build.

The below instructions assume you're going to be building for the **google** platform flavor and original **oba** brand by default (e.g., `obaGoogleDebug`), but
also mention how you would build/run the **amazon** flavor for the **oba** brand (e.g., `obaAmazonDebug`). If you want more info about building the other brands, please see the [Rebranding OneBusAway Android page](https://github.com/OneBusAway/onebusaway-android/blob/master/REBRANDING.md).
The below instructions assume you're going to be building for the **google** platform flavor and original **oba** brand by default (e.g., `obaGoogleDebug`).

If you want more info about building the other brands, please see the [Rebranding OneBusAway Android page](https://github.com/OneBusAway/onebusaway-android/blob/master/REBRANDING.md).

### Prerequisites for both Android Studio and Gradle

Expand All @@ -29,16 +29,16 @@ also mention how you would build/run the **amazon** flavor for the **oba** brand
1. At the welcome screen select `Import Project`, browse to the location of this repository and select it then select Ok.
1. Open the Android SDK Manager (Tools->Android->SDK Manager) and add a checkmark for the necessary API level (see `compileSdkVersion` in [`onebusaway-android/build.gradle`](onebusaway-android/build.gradle)) then select OK.
1. Connect a [debugging enabled](https://developer.android.com/tools/device.html) Android device to your computer or setup an Android Virtual Device (Tools->Andorid->AVD Manager).
1. Open the "Build Variants" window (it appears as a vertical button on left side of workspace by default) & choose **obaGoogleDebug** to select the Google Play version, or **obaAmazonDebug** to select the Fire Phone.
1. Open the "Build Variants" window (it appears as a vertical button on left side of workspace by default) & choose **obaGoogleDebug** to select the Google Play version.
1. Click the green play button (or Alt+Shift+F10) to build and run the project!

### Building from the command line using Gradle

1. Set the `JAVA_HOME` environmental variables to point to your JDK folder (e.g. `C:\Program Files\Java\jdk1.6.0_27`)
1. Download and install the [Android SDK](http://developer.android.com/sdk/index.html). Make sure to install the Google APIs for your API level (e.g. 17), the Android SDK Build-tools version for your `buildToolsVersion` version, the Android Support Repository and the Google Repository.
1. Set the `ANDROID_HOME` environmental variable to your Android SDK location.
1. To build and push the app to the device, run `gradlew installObaGoogleDebug` from the command line at the root of the project (or `gradlew installObaAmazonDebug` for Amazon build flavor)
1. To start the app, run `adb shell am start -n com.joulespersecond.seattlebusbot/org.onebusaway.android.ui.HomeActivity` (alternately, you can manually start the app)
1. Set the `ANDROID_HOME` environment variable to your Android SDK location.
1. To build and push the app to the device, run `gradlew installObaGoogleDebug` from the command line at the root of the project.
1. To start the app, run `adb shell am start -n com.joulespersecond.seattlebusbot/org.onebusaway.android.ui.HomeActivity` (alternately, you can manually start the app).

### Configuration Pelias API key for geocoding

Expand Down Expand Up @@ -77,7 +77,7 @@ Then, to build all flavors run:

`gradlew assembleRelease`

(If you want to assemble just the Google variant, use `gradlew assembleObaGoogleRelease`, and for Amazon Fire Phone-only use `gradlew assembleObaAmazonRelease`)
(If you want to assemble just the Google variant, use `gradlew assembleObaGoogleRelease`

The APK files will show up in the `onebusaway-android/build/outputs/apk` folder. `obaGoogleRelease-vx.y.z.apk` is the file that's uploaded to Google Play for release.

Expand Down Expand Up @@ -124,13 +124,4 @@ Note that after promoting a beta to production you should go back to GitHub and

### Releasing to Amazon App Store

I haven't done a release to the Amazon App Store in a long time because I don't want to break the app for existing users. I haven't had a device to test Amazon Maps for a while, so for now the APK is available on GitHub for users with Amazon devices that are adventurous enough to use it.

### Updating the Amazon Maps API library

Occasionally Amazon will likely release updates to their `amazon-maps-api-v2` library. These artifacts aren't currently hosted on Maven Central or Jcenter. As a result, when they release an update, we need to update our bundled Maven repo with the new artifact. The steps to do this are:

1. Download updated Amazon Maps API `aar` and `pom` files
1. Download [Apache Maven](https://maven.apache.org/download.cgi) & unzip Apache Maven (installation not required)
1. Run following command, replacing appropriate paths:
`path-to-bin-folder-of-maven/mvn install:install-file -Dfile=path-to-amazon-files/amazon-maps-api-v2.aar -DpomFile=path-to-amazon-files/amazon-maps-api-v2.pom -DlocalRepositoryPath=path-to-git-repo/.m2/repository`
We have fully deprecated support for the Amazon App Store. We won't pull the existing release from there, or remove the existing APKs from GitHub, but consider support for this platform to be EOL'd.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ This is the official Android / Fire Phone app for [OneBusAway](https://onebusawa
alt="Get it on Google Play"
height="80">](https://play.google.com/store/apps/details?id=com.joulespersecond.seattlebusbot)

[<img src="https://images-na.ssl-images-amazon.com/images/G/01/mobile-apps/devportal2/res/images/amazon-underground-app-us-black.png"
alt="Amazon App Store"
height="60">](http://www.amazon.com/gp/mas/dl/android?p=com.joulespersecond.seattlebusbot)

<image src="https://user-images.githubusercontent.com/928045/29891146-14ee4f44-8d98-11e7-999b-63f5d2ece916.gif" width="240" height="427" align=right />

OneBusAway for Android provides:
Expand Down Expand Up @@ -46,7 +42,7 @@ Curious what servers power certain features in OneBusAway Android? Check out th
There are two ways to deploy OneBusAway Android in your city:

1. **Join the OneBusAway [multi-region project](https://github.com/OneBusAway/onebusaway/wiki/Multi-Region)** - The easiest way to get started - simply set up your own OneBusAway server with your own transit data, and get added to the OneBusAway apps! See [this page](https://github.com/OneBusAway/onebusaway/wiki/Multi-Region) for details.
2. **Deploy a rebranded version of OneBusAway Android as your own app on Google Play** - Requires a bit more maintenance, but it allows you to set up your own app on Google Play / Amazon App Store based on the OneBusAway Android source code. See [rebranding page](https://github.com/OneBusAway/onebusaway-android/blob/master/REBRANDING.md) for details.
2. **Deploy a rebranded version of OneBusAway Android as your own app on Google Play** - Requires a bit more maintenance, but it allows you to set up your own app on Google Play based on the OneBusAway Android source code. See [rebranding page](https://github.com/OneBusAway/onebusaway-android/blob/master/REBRANDING.md) for details.

## Testing Your Own OneBusAway/OpenTripPlanner servers

Expand Down
7 changes: 3 additions & 4 deletions REBRANDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
There are two ways to deploy OneBusAway Android in your city:

1. **Join the OneBusAway [multi-region project](https://github.com/OneBusAway/onebusaway/wiki/Multi-Region)** - The easiest way to get started - simply set up your own OneBusAway server with your own transit data, and get added to *all* the OneBusAway apps! See [this page](https://github.com/OneBusAway/onebusaway/wiki/Multi-Region) for details.
2. **Deploy a rebranded version of OneBusAway Android as your own app on Google Play** - Requires a bit more maintenance, but it allows you to set up your own app on Google Play / Amazon App Store based on the OneBusAway Android source code, and with your brand name and colors. This page discusses this option in detail.
2. **Deploy a rebranded version of OneBusAway Android as your own app on Google Play** - Requires a bit more maintenance, but it allows you to set up your own app on Google Play based on the OneBusAway Android source code, and with your brand name and colors. This page discusses this option in detail.

## Rebranding Using Gradle Build Flavors

Expand All @@ -12,7 +12,6 @@ We use [Gradle build flavors](http://developer.android.com/tools/building/config
We have two Gradle "platform" flavor dimensions:

* **google** = Normal Google Play release
* **amazon** = Amazon Fire Phone release

...and three Gradle "brand" flavor dimensions:

Expand All @@ -30,9 +29,9 @@ And here are screenshots for these 3 brands:

<img src="https://cloud.githubusercontent.com/assets/928045/23876835/a6ceb718-0815-11e7-866a-5daef01d0a08.png" width="496" height="281" align=center />

Each of the 3 brands are deployed as an independent app on Google Play (using the **google** platform flavor) and the Amazon App Store (using the **amazon** platform flavor).
Each of the 3 brands are deployed as an independent app on Google Play (using the **google** platform flavor).

When building the project, this results in a total of 2 platforms * 3 brands = 6 core build variants. Each of these core variants also has a debug/release build type - the end result is that you'll have 12 build variants to choose from within Android Studio or on the command line.
When building the project, this results in a total of 1 platform * 3 brands = 3 core build variants. Each of these core variants also has a debug/release build type - the end result is that you'll have 6 build variants to choose from within Android Studio or on the command line.

To build a variant, you need to combine the platform flavor with the brand flavor. For example, the original OneBusAway brand for the Google platform can be build with:

Expand Down
28 changes: 0 additions & 28 deletions TROUBLESHOOTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,6 @@ In your `gradle.properties` file in the root of the project, add:

This must be at least 2 Gb to take advantage of Dex In Process. See [this post](https://medium.com/google-developers/faster-android-studio-builds-with-dex-in-process-5988ed8aa37e) for more info.

### When running the project, I get a NullPointerException in `BaseMapFragment`, related to `mMap`

You're most likely trying to run the `obaAmazon` build variant on an Google Android device, or the `obaGoogle` build flavor on an Amazon device.

To build the version of OneBusAway on Google Play, you'll want to select the `obaGoogleDebug` build variant.

Steps to set the build variant:

* In Android Studio, you'll see a "Build Variant" button on the very left side of the screen, collapsed in the dock. Click on this, and select either `obaGoogleDebug` for Google devices, or `obaAmazonDebug` for Amazon devices:
* From the command line, run `gradlew installObaGoogleDebug` for Google devices, or `gradlew installObaAmazonDebug` for Amazon devices.

![Android Studio build variants](https://02977090730444177945.googlegroups.com/attach/16c2dec220d69a/OBAAndroidGradleBuildFlavors.png?part=0.1&view=1&vt=ANaJVrEAdC5btUPS80q3eA4EO9z9asAZW7oRvJZMs5K8bZg0CCgIR8OwqvBR_21S58M2rbK7UVMbUc6QplQKuUyr5OwxLTu10NcK6R5XH3aKjktiU0cBONY)

See the documentation at the top of the readme for more information on building via Android Studio or the command line.

### When running the project I get prompted to install Amazon Maps. I already have Google Maps installed. What's going on?

This is likely due to running the `obaAmazon` build variant on an Google Android device. See the [top troubleshooting question](https://github.com/OneBusAway/onebusaway-android#when-running-the-project-i-get-a-nullpointerexception-in-basemapfragment-related-to-mmap), and make sure you select the `obaGoogleDebug` build variant.

### When running the project I get prompted to install Google Play Services. I have an Amazon Fire Phone that doesn't have Google Play Services. What's going on?

This is likely due to running the `obaGoogle` build variant on an Amazon Fire Phone. See the [top troubleshooting question](https://github.com/OneBusAway/onebusaway-android#when-running-the-project-i-get-a-nullpointerexception-in-basemapfragment-related-to-mmap), and make sure you select the `obaAmazonDebug` build variant.

### When importing to Android Studio, I get an error "You are using an old, unsupported version of Gradle..."

If you're using Android Studio v0.4.2 or lower, when importing, please be sure to select the `settings.gradle` file in the root, **NOT** the project directory.
You will get the above error if you select the project directory / name of the project.

### I get build errors for the Android Support libraries or Google APIs

Open the Android SDK Manager and make sure the following are installed:
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.5.30'
ext.kotlin_version = '1.6.21'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:8.2.0'
classpath 'com.google.gms:google-services:4.3.15'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
7 changes: 5 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=true
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx4g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
android.enableJetifier=true
android.useAndroidX=true
android.useAndroidX=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-all.zip
11 changes: 0 additions & 11 deletions onebusaway-android/AmazonMapsFileHeader.txt

This file was deleted.

Loading

0 comments on commit eca3888

Please sign in to comment.