taler-android

Android apps for GNU Taler (wallet, PoS, cashier)
Log | Files | Refs | README | LICENSE

build.gradle (7612B)


      1 /*
      2  * This file is part of GNU Taler
      3  * (C) 2020 Taler Systems S.A.
      4  *
      5  * GNU Taler is free software; you can redistribute it and/or modify it under the
      6  * terms of the GNU General Public License as published by the Free Software
      7  * Foundation; either version 3, or (at your option) any later version.
      8  *
      9  * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
     10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
     11  * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License along with
     14  * GNU Taler; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
     15  */
     16 
     17 import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
     18 
     19 plugins {
     20     id "com.android.application"
     21     id "kotlin-android"
     22     id "kotlinx-serialization"
     23     id "com.google.protobuf" version "0.9.5"
     24     id "org.jetbrains.kotlin.plugin.compose" version "$kotlin_version"
     25 }
     26 
     27 def qtart_version = "1.2.3"
     28 
     29 static def versionCodeEpoch() {
     30     return (new Date().getTime() / 1000).toInteger()
     31 }
     32 def gitCommit = { ->
     33     def stdout = new ByteArrayOutputStream()
     34     exec {
     35         commandLine 'git', 'rev-parse', '--short=7', 'HEAD'
     36         standardOutput = stdout
     37     }
     38     return stdout.toString().trim()
     39 }
     40 
     41 android {
     42     namespace 'net.taler.wallet'
     43     compileSdkVersion 36
     44 
     45     defaultConfig {
     46         applicationId "net.taler.wallet"
     47         minSdkVersion 24
     48         targetSdkVersion 36
     49         versionCode 69
     50         versionName "1.2.0"
     51         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     52     }
     53     buildTypes {
     54         release {
     55             minifyEnabled true
     56             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
     57         }
     58         debug {
     59             minifyEnabled minify_debug
     60             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
     61         }
     62     }
     63     flavorDimensions = ["distributionChannel"]
     64     productFlavors {
     65         fdroid {
     66             dimension "distributionChannel"
     67             applicationIdSuffix ".fdroid"
     68             // version codes get multiplied by 10 and an ABI suffix gets added to the code
     69             // if 'splitApk' property is set
     70         }
     71         google {
     72             dimension "distributionChannel"
     73         }
     74         nightly {
     75             dimension "distributionChannel"
     76             applicationIdSuffix ".nightly"
     77             versionCode versionCodeEpoch()
     78             versionNameSuffix " ($gitCommit)"
     79         }
     80     }
     81 
     82     compileOptions {
     83         sourceCompatibility = JavaVersion.VERSION_17
     84         targetCompatibility = JavaVersion.VERSION_17
     85 
     86         // Flag to enable support for the new language APIs for zxing
     87         coreLibraryDesugaringEnabled true
     88     }
     89 
     90     kotlinOptions {
     91         jvmTarget = "17"
     92     }
     93 
     94     buildFeatures {
     95         buildConfig true
     96         viewBinding true
     97     }
     98     packagingOptions {
     99         jniLibs {
    100             keepDebugSymbols += ['**/*.so']
    101         }
    102         resources {
    103             excludes += ['META-INF/*.kotlin_module']
    104         }
    105     }
    106     splits {
    107         abi {
    108             // can not be defined per flavor, so we use a property to turn this on for F-Droid
    109             enable project.hasProperty('splitApk')
    110             reset() // Resets the list of ABIs to remove all included by default
    111             include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
    112             universalApk false
    113         }
    114     }
    115 
    116     lint {
    117         abortOnError true
    118         ignoreWarnings false
    119     }
    120 }
    121 
    122 dependencies {
    123     implementation project(":taler-kotlin-android")
    124 
    125     implementation "net.taler:qtart:$qtart_version@aar"
    126 
    127     implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    128 
    129     implementation 'androidx.preference:preference-ktx:1.2.1'
    130     implementation "com.google.android.material:material:$material_version"
    131     implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
    132     implementation "androidx.browser:browser:1.9.0"
    133     implementation "androidx.biometric:biometric-ktx:1.4.0-alpha02"
    134 
    135     // Compose
    136     implementation platform('androidx.compose:compose-bom:2025.10.01')
    137     implementation 'androidx.compose.material3:material3'
    138     implementation 'androidx.compose.material:material-icons-extended'
    139     implementation "androidx.compose.runtime:runtime-livedata"
    140     implementation "androidx.lifecycle:lifecycle-viewmodel-compose"
    141     implementation "com.google.accompanist:accompanist-themeadapter-material3:0.36.0"
    142     implementation 'androidx.activity:activity-compose:1.11.0'
    143     implementation 'androidx.compose.ui:ui-tooling-preview'
    144     implementation 'androidx.compose.ui:ui-viewbinding'
    145     implementation "androidx.fragment:fragment-compose:1.8.9"
    146     debugImplementation 'androidx.compose.ui:ui-tooling'
    147 
    148     // Lists and Selection
    149     implementation "androidx.recyclerview:recyclerview:1.4.0"
    150     implementation "androidx.recyclerview:recyclerview-selection:1.2.0"
    151 
    152     // Navigation Library
    153     implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    154     implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    155 
    156     // ViewModel and LiveData
    157     implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    158 
    159     // QR codes
    160     implementation 'com.journeyapps:zxing-android-embedded:4.3.0@aar'
    161     // needed to support zxing library in taler-kotlin-android on API < 24
    162     coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
    163 
    164     // Nicer ProgressBar
    165     implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'
    166 
    167     // Markdown rendering
    168     final def markwon_version = '4.6.2'
    169     implementation "io.noties.markwon:core:$markwon_version"
    170     implementation "io.noties.markwon:ext-tables:$markwon_version"
    171     implementation "io.noties.markwon:recycler:$markwon_version"
    172 
    173     // Java Native Access (must always match JNA in qtart)
    174     implementation "net.java.dev.jna:jna:5.17.0@aar"
    175 
    176     // Shared preferences
    177     implementation "androidx.datastore:datastore:$datastore_version"
    178     implementation  "com.google.protobuf:protobuf-javalite:3.18.0"
    179 
    180     testImplementation "junit:junit:$junit_version"
    181     testImplementation 'org.json:json:20250517'
    182 }
    183 
    184 tasks.withType(KotlinCompile).configureEach {
    185     compilerOptions {
    186         freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
    187     }
    188 }
    189 
    190 // Map for the version code that gives each ABI a value.
    191 ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4]
    192 // For each APK output variant, override versionCode with a combination of ext.abiCodes + variant.versionCode.
    193 android.applicationVariants.configureEach { variant ->
    194     // Assigns a different version code for each output APK
    195     variant.outputs.each { output ->
    196         // Stores the value of ext.abiCodes that is associated with the ABI for this variant.
    197         def baseAbiVersionCode =
    198                 // Determines the ABI for this variant and returns the mapped value.
    199                 project.ext.abiCodes.get(output.getFilter(com.android.build.OutputFile.ABI))
    200         if (baseAbiVersionCode != null) {
    201             output.versionCodeOverride = 10 * variant.versionCode + baseAbiVersionCode
    202         }
    203         // leaves version code alone of there's no baseAbiVersionCode
    204     }
    205 }
    206 
    207 protobuf {
    208     protoc {
    209         artifact = "com.google.protobuf:protoc:4.28.3"
    210     }
    211 
    212     generateProtoTasks {
    213         all().each { task ->
    214             task.builtins {
    215                 java {
    216                     option 'lite'
    217                 }
    218             }
    219         }
    220     }
    221 }