Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Android CI

on:
push:
branches:
- master
- test/**
pull_request:
types: [opened, synchronize, reopened]

env:
ANDROID_API: 36.1
ANDROID_BUILD_TOOLS: 36.1.0
ADB_INSTALL_TIMEOUT: 5

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'

- name: Cache Gradle Build Cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches/build-cache-*
key: ${{ runner.os }}-gradle-build-cache-${{ github.sha }}
restore-keys: |
${{ runner.os }}-gradle-build-cache-

- name: Restore cache for Git LFS Objects
id: lfs-cache
uses: actions/cache@v4
with:
path: .git/lfs
key: ${{ runner.os }}-lfs-${{ hashFiles('.git/lfs/objects/**') }}
restore-keys: ${{ runner.os }}-lfs-

- name: Git LFS Pull
run: git lfs pull

- name: Setup Android SDK
uses: android-actions/setup-android@v3

- name: Install Android SDK components
run: |
sdkmanager "tools"
sdkmanager "build-tools;${ANDROID_BUILD_TOOLS}"
sdkmanager "platforms;android-${ANDROID_API}"
sdkmanager "extras;android;m2repository"
sdkmanager "extras;google;m2repository"
sdkmanager "extras;google;google_play_services"

- name: Prepare builddir
run: |
# secrets are only available for collabrators, other will build with OsmDroid (but a few more options than F-Droid still)
echo "${{ secrets.MAPBOX }}" > $GITHUB_WORKSPACE/mapbox.properties
echo "${{ secrets.DROPBOX }}" > $GITHUB_WORKSPACE/dropbox.properties
echo "${{ secrets.RUNALYZE }}" > $GITHUB_WORKSPACE/runalyze.properties
chmod +x gradlew

- name: Build bundle
run: ./gradlew :app:bundleLatestRelease :wear:bundleRelease

- name: Upload build logs
if: always()
uses: actions/upload-artifact@v4
with:
name: build-bundle
# possibly include: app/build/outputs/bundle/latestRelease/ wear/build/outputs/bundle/release/
path: |
**/build/outputs/logs/

- name: Test
run: ./gradlew testBuildTypesUnitTest :app:testLatestDebugUnitTest testDebugUnitTest

- name: Upload test logs
if: always()
uses: actions/upload-artifact@v4
with:
name: test-logs
path: |
**/build/reports/tests/

- name: Lint latest release
run: ./gradlew :app:lintLatestRelease :wear:lintRelease :hrdevice:lintRelease :common:lintRelease

- name: Upload lint logs
if: always()
uses: actions/upload-artifact@v4
with:
name: lint-logs
path: |
**/build/reports/lint-results-release.html
**/build/reports/lint-results-latestRelease.html

- name: Build F-Droid
run: |
rm $GITHUB_WORKSPACE/mapbox.properties
# For special build steps, see https://gitlab.com/fdroid/fdroiddata.git metadata/org.runnerup.free.yml
rm -rf wear ANT-Android-SDKs $GITHUB_WORKSPACE/dropbox.properties $GITHUB_WORKSPACE/runalyze.properties
sed -i -e '/play-services/d' -e '/mapboxsdk/d' -e '/api.mapbox.com/d' app/build.gradle
sed -i -e '/wearable/d' common/build.gradle
./gradlew clean :app:assembleLatestRelease

- name: Upload F-Droid logs
if: always()
uses: actions/upload-artifact@v4
with:
name: fdroid-logs
path: |
build/reports/problems/
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

130 changes: 51 additions & 79 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ def getGitHash = providers.exec {

android {
buildToolsVersion = rootProject.ext.buildToolsVersion
namespace 'org.runnerup'
namespace = 'org.runnerup'

compileOptions {
sourceCompatibility JavaVersion.toVersion("17")
targetCompatibility JavaVersion.toVersion("17")
sourceCompatibility = JavaVersion.toVersion("17")
targetCompatibility = JavaVersion.toVersion("17")
}

sourceSets {
Expand All @@ -29,7 +29,7 @@ android {
}
if (rootProject.ext.noMap) {
java.srcDirs += ['src/nomap']
} else if (rootProject.ext.useMapBox) {
} else if (rootProject.ext.mapboxEnabled) {
java.srcDirs += ['src/mapbox']
} else {
java.srcDirs += ['src/osmdroid']
Expand All @@ -44,13 +44,13 @@ android {
flavorDimensions = [ "all" ]
productFlavors {
latest {
dimension "all"
dimension = "all"
// multidexing support, min play support
minSdk rootProject.ext.minSdk
compileSdk rootProject.ext.compileSdk
targetSdk rootProject.ext.targetSdk
versionName rootProject.ext.versionName
versionCode rootProject.ext.latestBaseVersionCode + rootProject.ext.versionCode
minSdk = rootProject.ext.minSdk
compileSdk = rootProject.ext.compileSdk
targetSdk = rootProject.ext.targetSdk
versionName = rootProject.ext.versionName
versionCode = rootProject.ext.latestBaseVersionCode + rootProject.ext.versionCode
}
}

Expand All @@ -60,7 +60,7 @@ android {
// enable rootProject.ext.allowNonFree && gradle.startParameter.taskNames.contains("assembleLatestRelease")
// relevant archs only - these are the only available anyway for newer NDK
include 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
universalApk true
universalApk = true
}
}

Expand All @@ -86,22 +86,30 @@ android {
versionNameSuffix = "-${getGitHash}"
}
release {
debuggable false
applicationIdSuffix ""
debuggable = false
applicationIdSuffix = ""

minifyEnabled rootProject.ext.allowNonFree
shrinkResources rootProject.ext.allowNonFree
minifyEnabled = rootProject.ext.allowNonFree
shrinkResources = rootProject.ext.allowNonFree
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard.txt'
signingConfig signingConfigs.release
signingConfig = signingConfigs.release
}
}
lint {
baseline file('lint-baseline.xml')
checkReleaseBuilds true
lintConfig file('lint.xml')
showAll true
//textOutput 'stdout'
textReport true
baseline = file('lint-baseline.xml')
checkReleaseBuilds = true
if (mapboxEnabled) {
lintConfig = file('lint.xml')
} else {
lintConfig = file('lint-osmdroid.xml')
}
showAll = true
//textOutput = 'stdout'
textReport = true
// Treat all warnings as errors
warningsAsErrors = true
// Halt the build if any errors are found
abortOnError = true
}
bundle {
language {
Expand All @@ -110,21 +118,21 @@ android {
}
}
buildFeatures {
aidl true
buildConfig true
aidl = true
buildConfig = true
}
androidResources {
generateLocaleConfig true
generateLocaleConfig = true
}
}

repositories {
google()
mavenCentral() //MapBox GraphView
maven { url "https://oss.sonatype.org/content/groups/public/" } //pebblekit
if (rootProject.ext.useMapBox) {
maven { url = "https://oss.sonatype.org/content/groups/public/" } //pebblekit
if (rootProject.ext.mapboxEnabled) {
maven {
url 'https://api.mapbox.com/downloads/v2/releases/maven'
url = 'https://api.mapbox.com/downloads/v2/releases/maven'
authentication {
basic(BasicAuthentication)
}
Expand All @@ -144,10 +152,10 @@ repositories {
// Duplicate class kotlin.collections.jdk8 (from MapBox?)
dependencies {
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:2.2.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.2.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
Expand All @@ -163,7 +171,7 @@ dependencies {
implementation "androidx.viewpager2:viewpager2:1.1.0"
implementation "androidx.constraintlayout:constraintlayout:2.2.1"

latestImplementation "com.google.android.material:material:1.12.0"
latestImplementation "com.google.android.material:material:1.13.0"
if (rootProject.ext.enableWear) {
// Build Wear separately, do not include in phone apk
// latestWearApp project(':wear')
Expand All @@ -172,13 +180,13 @@ dependencies {
latestImplementation "com.google.android.gms:play-services-wearable:${rootProject.ext.googlePlayServicesWearableVersion}"
}

implementation "com.squareup.okhttp3:okhttp:5.1.0"
implementation "com.squareup.okhttp3:okhttp:5.3.2"
latestImplementation 'com.getpebble:pebblekit:4.0.1'
if (rootProject.ext.allowNonFree) {
// MapBox uses telemetry, without Play there may be exceptions from mapbox (OK to ignore)
latestImplementation "com.google.android.gms:play-services-location:${rootProject.ext.googlePlayServicesVersion}"
}
if (rootProject.ext.useMapBox) {
if (rootProject.ext.mapboxEnabled) {
//noinspection GradleDependency
latestImplementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.6.2'
latestImplementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-annotation-v9:0.9.0'
Expand All @@ -202,6 +210,7 @@ allprojects {
}

def props = new Properties()
// For locally signed builds only, Google Play signs the bundle
if (rootProject.file("release.properties").exists()) {
props.load(new FileInputStream(rootProject.file("release.properties")))

Expand All @@ -215,54 +224,17 @@ if (rootProject.file("release.properties").exists()) {
}

android.applicationVariants.configureEach {
// Note: As a minimum extra security at least obfuscate the strings with Proguard
if (rootProject.ext.noMap) {
buildConfigField 'boolean', 'USING_OSMDROID', "false"
buildConfigField 'int', 'MAPBOX_ENABLED', "0"
buildConfigField 'String', 'MAPBOX_ACCESS_TOKEN', '""'
} else if (rootProject.ext.useMapBox) {
// https://www.mapbox.com/account/
props.load(new FileInputStream(rootProject.file("mapbox.properties")))
buildConfigField 'int', 'MAPBOX_ENABLED', "1"
buildConfigField 'String', 'MAPBOX_ACCESS_TOKEN', props.mapboxAccessToken

buildConfigField 'boolean', 'USING_OSMDROID', "false"
} else {
buildConfigField 'int', 'MAPBOX_ENABLED', "0"
buildConfigField 'String', 'MAPBOX_ACCESS_TOKEN', '""'
buildConfigField 'boolean', 'USING_OSMDROID', "true"
}
buildConfigField 'boolean', 'MAPBOX_ENABLED', "${rootProject.ext.mapboxEnabled}"
buildConfigField 'String', 'MAPBOX_ACCESS_TOKEN', "\"${rootProject.ext.mapboxAccessToken}\""
buildConfigField 'boolean', 'OSMDROID_ENABLED', "${rootProject.ext.osmdroidEnabled}"

if (rootProject.file("runalyze.properties").exists()) {
// Contact Runalyze team at https://forum.runalyze.com/
props.load(new FileInputStream(rootProject.file("runalyze.properties")))
buildConfigField 'int', 'RUNALYZE_ENABLED', "1"
buildConfigField 'String', 'RUNALYZE_ID', props.CLIENT_ID
buildConfigField 'String', 'RUNALYZE_SECRET', props.CLIENT_SECRET
} else {
// Demo, connect to testing.runalyze.com
buildConfigField 'int', 'RUNALYZE_ENABLED', "0"
buildConfigField 'String', 'RUNALYZE_ID', '"8_2jx5jt9r39ic40ooc80c8c0884okgk0owsowg808c4csg8ko8g"'
buildConfigField 'String', 'RUNALYZE_SECRET', '"1v7d6nwe1v9c8skok44g0gc8cc04cc0wwwo8swwgckoogwsww4"'
}
buildConfigField 'boolean', 'RUNALYZE_ENABLED', "${rootProject.ext.runalyzeEnabled}"
buildConfigField 'String', 'RUNALYZE_ID', "\"${rootProject.ext.runalyzeId}\""
buildConfigField 'String', 'RUNALYZE_SECRET', "\"${rootProject.ext.runalyzeSecret}\""

if (rootProject.file("dropbox.properties").exists()) {
// Create an app at https://www.dropbox.com/developers/apps/
// Dropbox API, App folder -> create app
// Enable additional users, Redirect URI:http://localhost:8080/runnerup/dropbox, Disallow implicit grant
// Set branding icon
// Create dropbox.properties with two lines:
// CLIENT_ID="replace_dropbox_id"
// CLIENT_SECRET="replace_dropbox_secret"
props.load(new FileInputStream(rootProject.file("dropbox.properties")))
buildConfigField 'int', 'DROPBOX_ENABLED', "1"
buildConfigField 'String', 'DROPBOX_ID', props.CLIENT_ID
buildConfigField 'String', 'DROPBOX_SECRET', props.CLIENT_SECRET
} else {
buildConfigField 'int', 'DROPBOX_ENABLED', "0"
buildConfigField 'String', 'DROPBOX_ID', "null"
buildConfigField 'String', 'DROPBOX_SECRET', "null"
}
buildConfigField 'boolean', 'DROPBOX_ENABLED', "${rootProject.ext.dropboxEnabled}"
buildConfigField 'String', 'DROPBOX_ID', "\"${rootProject.ext.dropboxId}\""
buildConfigField 'String', 'DROPBOX_SECRET', "\"${rootProject.ext.dropboxSecret}\""
}

//Based on an example from https://developer.android.com/studio/build/configure-apk-splits.html
Expand Down
Loading
Loading