188 lines
6.8 KiB
Groovy
188 lines
6.8 KiB
Groovy
plugins {
|
|
id 'com.android.application'
|
|
id 'kotlin-android'
|
|
id 'kotlin-kapt'
|
|
}
|
|
|
|
def appId = "deckers.thibault.aves"
|
|
|
|
// Flutter properties
|
|
|
|
def localProperties = new Properties()
|
|
def localPropertiesFile = rootProject.file('local.properties')
|
|
if (localPropertiesFile.exists()) {
|
|
localPropertiesFile.withReader('UTF-8') { reader ->
|
|
localProperties.load(reader)
|
|
}
|
|
}
|
|
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
|
|
def flutterVersionName = localProperties.getProperty('flutter.versionName')
|
|
def flutterRoot = localProperties.getProperty('flutter.sdk')
|
|
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
|
|
|
// Keys
|
|
|
|
def keystoreProperties = new Properties()
|
|
def keystorePropertiesFile = rootProject.file('key.properties')
|
|
if (keystorePropertiesFile.exists()) {
|
|
// for release using credentials stored in a local file
|
|
keystorePropertiesFile.withReader('UTF-8') { reader ->
|
|
keystoreProperties.load(reader)
|
|
}
|
|
} else {
|
|
// for release using credentials in environment variables set up by GitHub Actions
|
|
// warning: in property file, single quotes should be escaped with a backslash
|
|
// but they should not be escaped when stored in env variables
|
|
keystoreProperties['storeFile'] = System.getenv('AVES_STORE_FILE')
|
|
keystoreProperties['storePassword'] = System.getenv('AVES_STORE_PASSWORD')
|
|
keystoreProperties['keyAlias'] = System.getenv('AVES_KEY_ALIAS')
|
|
keystoreProperties['keyPassword'] = System.getenv('AVES_KEY_PASSWORD')
|
|
keystoreProperties['googleApiKey'] = System.getenv('AVES_GOOGLE_API_KEY')
|
|
}
|
|
|
|
android {
|
|
compileSdkVersion 32
|
|
|
|
sourceSets {
|
|
main.java.srcDirs += 'src/main/kotlin'
|
|
}
|
|
|
|
|
|
defaultConfig {
|
|
applicationId appId
|
|
// minSdkVersion constraints:
|
|
// - Flutter & other plugins: 16
|
|
// - google_maps_flutter v2.1.1: 20
|
|
// - to build XML documents from XMP data, `metadata-extractor` and `PixyMeta` rely on `DocumentBuilder`,
|
|
// which implementation `DocumentBuilderImpl` is provided by the OS and is not customizable on Android,
|
|
// but the implementation on API <19 is not robust enough and fails to build XMP documents
|
|
minSdkVersion 19
|
|
targetSdkVersion 32
|
|
versionCode flutterVersionCode.toInteger()
|
|
versionName flutterVersionName
|
|
manifestPlaceholders = [googleApiKey: keystoreProperties['googleApiKey']]
|
|
multiDexEnabled true
|
|
resValue 'string', 'search_provider', "${appId}.search_provider"
|
|
}
|
|
|
|
signingConfigs {
|
|
release {
|
|
keyAlias keystoreProperties['keyAlias']
|
|
keyPassword keystoreProperties['keyPassword']
|
|
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
|
|
storePassword keystoreProperties['storePassword']
|
|
}
|
|
}
|
|
|
|
flavorDimensions "store"
|
|
|
|
productFlavors {
|
|
play {
|
|
// Google Play
|
|
dimension "store"
|
|
ext.useCrashlytics = true
|
|
ext.useHMS = false
|
|
// generate a universal APK without x86 native libs
|
|
ext.useNdkAbiFilters = true
|
|
}
|
|
|
|
huawei {
|
|
// Huawei AppGallery
|
|
dimension "store"
|
|
ext.useCrashlytics = false
|
|
ext.useHMS = true
|
|
// generate a universal APK without x86 native libs
|
|
ext.useNdkAbiFilters = true
|
|
}
|
|
|
|
izzy {
|
|
// IzzyOnDroid
|
|
// check offending libraries with `scanapk`
|
|
// cf https://android.izzysoft.de/articles/named/app-modules-2
|
|
dimension "store"
|
|
ext.useCrashlytics = false
|
|
ext.useHMS = false
|
|
// generate APK by ABI, but NDK ABI filters are incompatible with split APK generation
|
|
ext.useNdkAbiFilters = false
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
debug {
|
|
applicationIdSuffix ".debug"
|
|
resValue 'string', 'search_provider', "${appId}.debug.search_provider"
|
|
}
|
|
profile {
|
|
applicationIdSuffix ".profile"
|
|
resValue 'string', 'search_provider', "${appId}.profile.search_provider"
|
|
}
|
|
release {
|
|
signingConfig signingConfigs.release
|
|
minifyEnabled true
|
|
shrinkResources true
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
}
|
|
|
|
android.productFlavors.each { flavor ->
|
|
def tasks = gradle.startParameter.taskNames.toString().toLowerCase()
|
|
if (tasks.contains(flavor.name) && flavor.ext.useNdkAbiFilters) {
|
|
release {
|
|
// specify architectures, to specifically exclude native libs for x86,
|
|
// which lead to: UnsatisfiedLinkError...couldn't find "libflutter.so"
|
|
// cf https://github.com/flutter/flutter/issues/37566#issuecomment-640879500
|
|
ndk {
|
|
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
lint {
|
|
disable 'InvalidPackage'
|
|
}
|
|
}
|
|
|
|
flutter {
|
|
source '../..'
|
|
}
|
|
|
|
repositories {
|
|
maven { url 'https://jitpack.io' }
|
|
maven { url 'https://s3.amazonaws.com/repo.commonsware.com' }
|
|
}
|
|
|
|
dependencies {
|
|
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
|
|
implementation 'androidx.core:core-ktx:1.7.0'
|
|
implementation 'androidx.exifinterface:exifinterface:1.3.3'
|
|
implementation 'androidx.multidex:multidex:2.0.1'
|
|
implementation 'com.caverock:androidsvg-aar:1.4'
|
|
implementation 'com.commonsware.cwac:document:0.4.1'
|
|
implementation 'com.drewnoakes:metadata-extractor:2.18.0'
|
|
// forked, built by JitPack, cf https://jitpack.io/p/deckerst/Android-TiffBitmapFactory
|
|
implementation 'com.github.deckerst:Android-TiffBitmapFactory:876e53870a'
|
|
// forked, built by JitPack, cf https://jitpack.io/p/deckerst/pixymeta-android
|
|
implementation 'com.github.deckerst:pixymeta-android:706bd73d6e'
|
|
implementation 'com.github.bumptech.glide:glide:4.13.2'
|
|
|
|
// huawei flavor only
|
|
huaweiImplementation 'com.huawei.agconnect:agconnect-core:1.5.2.300'
|
|
|
|
kapt 'androidx.annotation:annotation:1.3.0'
|
|
kapt 'com.github.bumptech.glide:compiler:4.13.0'
|
|
|
|
compileOnly rootProject.findProject(':streams_channel')
|
|
}
|
|
|
|
android.productFlavors.each { flavor ->
|
|
def tasks = gradle.startParameter.taskRequests.toString().toLowerCase()
|
|
if (tasks.contains(flavor.name) && flavor.ext.useCrashlytics) {
|
|
println("Building flavor [${flavor.name}] with Crashlytics plugin")
|
|
apply plugin: 'com.google.gms.google-services'
|
|
apply plugin: 'com.google.firebase.crashlytics'
|
|
}
|
|
if (tasks.contains(flavor.name) && flavor.ext.useHMS) {
|
|
println("Building flavor [${flavor.name}] with HMS plugin")
|
|
apply plugin: 'com.huawei.agconnect'
|
|
}
|
|
}
|