165 lines
6.7 KiB
Groovy
165 lines
6.7 KiB
Groovy
apply plugin: 'com.android.application'
|
|
|
|
// These are sample values to set in gradle.properties.secrets
|
|
// MY_KEYSTORE_FILE=time-safari-upload-key-pkcs12.jks
|
|
// MY_KEYSTORE_PASSWORD=...
|
|
// MY_KEY_ALIAS=time-safari-key-alias
|
|
// MY_KEY_PASSWORD=...
|
|
|
|
// Try to load from environment variables first
|
|
project.ext.MY_KEYSTORE_FILE = System.getenv('ANDROID_KEYSTORE_FILE') ?: ""
|
|
project.ext.MY_KEYSTORE_PASSWORD = System.getenv('ANDROID_KEYSTORE_PASSWORD') ?: ""
|
|
project.ext.MY_KEY_ALIAS = System.getenv('ANDROID_KEY_ALIAS') ?: ""
|
|
project.ext.MY_KEY_PASSWORD = System.getenv('ANDROID_KEY_PASSWORD') ?: ""
|
|
|
|
// If no environment variables, try to load from secrets file
|
|
if (!project.ext.MY_KEYSTORE_FILE) {
|
|
def secretsPropertiesFile = rootProject.file("app/gradle.properties.secrets")
|
|
if (secretsPropertiesFile.exists()) {
|
|
Properties secretsProperties = new Properties()
|
|
secretsProperties.load(new FileInputStream(secretsPropertiesFile))
|
|
secretsProperties.each { name, value ->
|
|
project.ext[name] = value
|
|
}
|
|
}
|
|
}
|
|
|
|
android {
|
|
namespace 'app.timesafari'
|
|
compileSdk rootProject.ext.compileSdkVersion
|
|
|
|
compileOptions {
|
|
// Backports java.time (API 26+) to older Android; the daily notification plugin uses it.
|
|
coreLibraryDesugaringEnabled true
|
|
sourceCompatibility JavaVersion.VERSION_21
|
|
targetCompatibility JavaVersion.VERSION_21
|
|
}
|
|
|
|
defaultConfig {
|
|
applicationId "app.timesafari.app"
|
|
minSdkVersion rootProject.ext.minSdkVersion
|
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
|
versionCode 77
|
|
versionName "1.4.11"
|
|
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 (project.ext.MY_KEYSTORE_FILE &&
|
|
project.ext.MY_KEYSTORE_PASSWORD &&
|
|
project.ext.MY_KEY_ALIAS &&
|
|
project.ext.MY_KEY_PASSWORD) {
|
|
|
|
storeFile file(project.ext.MY_KEYSTORE_FILE)
|
|
storePassword project.ext.MY_KEYSTORE_PASSWORD
|
|
keyAlias project.ext.MY_KEY_ALIAS
|
|
keyPassword project.ext.MY_KEY_PASSWORD
|
|
}
|
|
}
|
|
}
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled false
|
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
// Only sign if we have the signing config
|
|
if (signingConfigs.release.storeFile != null) {
|
|
signingConfig signingConfigs.release
|
|
}
|
|
}
|
|
}
|
|
packagingOptions {
|
|
jniLibs {
|
|
// Required for 16 KB page-size support: keep native libs uncompressed and
|
|
// page-aligned inside the APK (default on AGP 8.x with minSdk 23+, set
|
|
// explicitly so it does not regress).
|
|
useLegacyPackaging = false
|
|
pickFirsts += ['**/lib/x86_64/libbarhopper_v3.so', '**/lib/x86_64/libimage_processing_util_jni.so', '**/lib/x86_64/libsqlcipher.so']
|
|
}
|
|
}
|
|
|
|
// Enable bundle builds (without which it doesn't work right for bundleDebug vs bundleRelease)
|
|
bundle {
|
|
language {
|
|
enableSplit = true
|
|
}
|
|
density {
|
|
enableSplit = true
|
|
}
|
|
abi {
|
|
enableSplit = true
|
|
}
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
flatDir{
|
|
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:2.1.5"
|
|
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')
|
|
implementation project(':capacitor-community-sqlite')
|
|
implementation "androidx.biometric:biometric:1.2.0-alpha05"
|
|
|
|
// Daily Notification Plugin dependencies
|
|
implementation "androidx.room:room-runtime:2.6.1"
|
|
implementation "androidx.work:work-runtime-ktx:2.9.0"
|
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3"
|
|
annotationProcessor "androidx.room:room-compiler:2.6.1"
|
|
|
|
// Capacitor annotation processor for automatic plugin discovery
|
|
annotationProcessor project(':capacitor-android')
|
|
|
|
// Additional dependencies for notification plugin
|
|
implementation 'androidx.lifecycle:lifecycle-service:2.7.0'
|
|
implementation 'com.google.code.gson:gson:2.10.1'
|
|
|
|
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'
|
|
|
|
// Firebase is on for every build. Opt out only with -PfirebaseEnabled=false
|
|
// (F-Droid / other builds that must not apply the google-services plugin).
|
|
// The config file does not decide the switch: when Firebase is on, a missing
|
|
// file fails the build; when it is off, a file on disk is ignored.
|
|
def firebaseEnabledRaw = project.findProperty('firebaseEnabled')
|
|
def firebaseEnabled = true
|
|
if (firebaseEnabledRaw != null) {
|
|
def normalized = firebaseEnabledRaw.toString().trim().toLowerCase()
|
|
if (normalized == 'false' || normalized == '0' || normalized == 'no') {
|
|
firebaseEnabled = false
|
|
}
|
|
}
|
|
|
|
if (!firebaseEnabled) {
|
|
logger.lifecycle('Firebase disabled (-PfirebaseEnabled=false): google-services plugin not applied')
|
|
} else {
|
|
def servicesJSON = file('google-services.json')
|
|
def servicesBody = servicesJSON.isFile() ? servicesJSON.getText('UTF-8') : ''
|
|
if (!servicesBody.trim() || !servicesBody.contains('mobilesdk_app_id')) {
|
|
throw new GradleException(
|
|
'Firebase is enabled, but android/app/google-services.json is missing, empty, or has no mobilesdk_app_id.\n' +
|
|
'Download it from the Firebase console (Project settings → Your apps → Android app)\n' +
|
|
'and place it at android/app/google-services.json.\n' +
|
|
'To build without Firebase (F-Droid / FOSS), pass -PfirebaseEnabled=false.'
|
|
)
|
|
}
|
|
apply plugin: 'com.google.gms.google-services'
|
|
logger.lifecycle('Firebase enabled: google-services plugin applied')
|
|
}
|