Files
recurring-checklist/mobile/android/app/build.gradle
T

92 lines
4.2 KiB
Groovy
Raw Normal View History

apply plugin: 'com.android.application'
// Version numbers live in mobile/release.config.json, shared with the iOS build, so a
// release bumps ONE file instead of drifting between the two stores. Play permanently
// reserves every versionCode it has ever seen — a duplicate is rejected and the number can
// never be reused, even after deleting the release — so this must always come from the
// file that release.sh increments.
def releaseConfig = new groovy.json.JsonSlurper().parseText(file('../../release.config.json').getText('UTF-8'))
// Signing credentials are read from mobile/keystore.properties, which is gitignored and
// never checked in. Absent (a fresh clone, a CI box), release builds simply come out
// unsigned rather than failing the whole Gradle configuration phase.
// NOTE the '../': rootProject here is mobile/android, not mobile. Pointing at
// 'keystore.properties' silently finds nothing, and an unsigned AAB builds happily and is
// only rejected once you upload it to Play — so this path is load-bearing.
def keystorePropsFile = rootProject.file('../keystore.properties')
def keystoreProps = new Properties()
if (keystorePropsFile.exists()) {
keystorePropsFile.withInputStream { keystoreProps.load(it) }
}
android {
namespace = "org.waterschurch.checklist"
compileSdk = rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "org.waterschurch.checklist"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode releaseConfig.androidVersionCode
versionName releaseConfig.version
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
ignoreAssetsPattern = '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
signingConfigs {
release {
if (keystorePropsFile.exists()) {
storeFile file(keystoreProps['storeFile'])
storePassword keystoreProps['storePassword']
keyAlias keystoreProps['keyAlias']
keyPassword keystoreProps['keyPassword']
}
}
}
buildTypes {
release {
if (keystorePropsFile.exists()) {
signingConfig signingConfigs.release
}
// minifyEnabled stays false on purpose. All the app's logic is JavaScript in
// assets/public/, which R8 never touches; the only Java here is Capacitor's
// bridge and its plugins, where shrinking buys a couple hundred KB in exchange
// for reflection-based plugin registration breaking in ways that only show up
// in a signed release build.
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation "androidx.coordinatorlayout:coordinatorlayout:$androidxCoordinatorLayoutVersion"
implementation "androidx.core:core-splashscreen:$coreSplashScreenVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
}
apply from: 'capacitor.build.gradle'
try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.info("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}