To compile and sign the app, you must add a directory called private
(beiwe-android
's .gitignore
file keeps the private
directory out of Git), and a file called private/keystore.properties
, containing these lines (no quotes around the values that you fill in):
storePassword=KEYSTORE_PASSWORD
keyPassword=KEY_PASSWORD
keyAlias=KEY_ALIAS
storeFile=KEYSTORE_FILEPATH
If it's your first time running the project, open Android Studio and click "Sync Project with Gradle Files". If you run into errors, open Android Studio's "SDK Manager" and make sure you have the correct SDK Platform installed (the "API level" should match the one specified in app/build.gradle's compileSdkVersion
).
You'll need to generate a key file by running Build -> Generate Signed Bundle/APK, and then, inside private/keystore.properties
, update the four values with the information from your newly-generated key and keystore.
(Optional) You can also configure a Sentry DSN for each build type inside your private/keystore.properties
file.
releaseDSN=https://publicKey:secretKey@host:port/1?options
betaDSN=https://publicKey:secretKey@host:port/1?options
developmentDSN=https://publicKey:secretKey@host:port/1?options
To receive push notifications, add Firebase to your Android Project following these steps up through Step 3.
When you build the Android app, you choose one of the Build Variants and one of the Product Flavors. There are three of each, specified in the buildTypes
section of app/build.gradle
. To select which Build Variant the app compiles as, go to Build > Select Build Variant in the menu bar (see the documentation).
Build Variant | App name | Password requirements | Debug interface |
---|---|---|---|
release | "Beiwe" or "Beiwe2" | At least 6 characters | No |
beta | "Beiwe-beta" or "Beiwe2-beta" | At least 1 character | Yes |
development | "Beiwe-development" or "Beiwe2-development" | At least 1 character | Yes, plus extra buttons only useful for develpers, like buttons to crash the app. Also includes some extra logging statements that write to LogCat, but not to app log files that get uploaded. |
Product Flavor | App Name | Intended for | Server URL | Record text message and call log stats | Request background location permission |
---|---|---|---|---|---|
googlePlayStore | Beiwe2 | Distribution via Google Play Store | Customizable at registration | No (forbidden by Play Store policies) | No (forbidden by Play Store policies) |
onnelaLabServer | Beiwe | Download APK from studies.beiwe.org/download | Hardcoded to studies.beiwe.org | Yes | Yes |
commStatsCustomUrl | Beiwe | Download APK from /download link on other Beiwe deployments |
Customizable at registration | Yes | Yes |
This section is only intended for developers maintaining the canonical copies of the Beiwe and Beiwe2 Android apps; this is not useful for anyone working on a fork of the repo.
When we update the app version, we need to update the three public versions of the app: the googlePlayStore flavor that's downloadable from Google Play, and the onnelaLabServer and commStatsCustomUrl flavors which get compiled as APKs, stored in a public bucket on Amazon S3, and linked to via /download
links on other Beiwe deployments.
We use Fastlane, running inside GitHub Actions, for building and distributing the app.
app/build.gradle
, increment versionCode
(a sequential integer) and increase versionName
(a traditional x.y.z format version number).DeviceInfo.java
, write a message about what changes the new version brings.master
that only does the above two things, and does not introduce any other changes. I like to use a commit message formatted exactly like this: Updates app version to x.y.z, level XX
. Then, only make builds off of this commit. That way it's very clear what Git commit each build corresponds to. If you want to change something in the build, create a new version.fastlane buildAAB
builds the AAB file and uploads it to Google Play's "Alpha" (closed testing) track.fastlane buildAPKs
builds the two APK files (onnelaLabServer and commStatsCustomUrl) and uploads them to the S3 bucket. It uploads two copies of each file:
/download
link should point to.You shouldn't need to do this, other than for debugging the Fastlane setup. We intend Fastlane to be primarily run on the cloud, inside GitHub Actions. But if for some reason you decide to run it locally, here's how to do it:
gem install bundler
, and then bundle install
.private/signing_keystore.jks
private/keystore.properties
file, which should include releaseDSN
faslane/Appfile
.AWS_ACCESS_KEY_ID
and AWS_SECRET_ACCESS_KEY
.fastlane buildAAB
fastlane buildAPKs