taler-android

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

build.gradle (8633B)


      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 "$protobuf_version"
     24     id "org.jetbrains.kotlin.plugin.compose" version "$kotlin_version"
     25 }
     26 
     27 def qtart_version = "1.6.49"
     28 
     29 static def versionCodeEpoch() {
     30     return (new Date().getTime() / 1000).toInteger()
     31 }
     32 
     33 def gitCommit = { ->
     34     return 'git rev-parse --short=7 HEAD'.execute().text.trim()
     35 }
     36 
     37 android {
     38     namespace 'net.taler.wallet'
     39     compileSdkVersion 37
     40 
     41     defaultConfig {
     42         applicationId "net.taler.wallet"
     43         minSdkVersion 24
     44         targetSdkVersion 37
     45         versionCode 101
     46         versionName "1.6.9"
     47         testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
     48     }
     49     // The androidTest variant is only created for the testBuildType, and
     50     // enableAndroidTestCoverage only instruments the app's classes when such a
     51     // variant exists -- so the simulator's build type has to be the one.
     52     // Nothing else in the repo has instrumented tests, so this costs nothing.
     53     testBuildType "sim"
     54     buildTypes {
     55         release {
     56             minifyEnabled true
     57             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
     58         }
     59         debug {
     60             minifyEnabled minify_debug
     61             proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
     62             applicationIdSuffix ".debug"
     63             enableUnitTestCoverage true
     64         }
     65         sim {
     66             initWith debug
     67             signingConfig signingConfigs.debug
     68             minifyEnabled false
     69             enableAndroidTestCoverage true
     70             enableUnitTestCoverage true
     71             matchingFallbacks = ['debug']
     72         }
     73     }
     74     flavorDimensions = ["distributionChannel"]
     75     productFlavors {
     76         fdroid {
     77             dimension "distributionChannel"
     78             applicationIdSuffix ".fdroid"
     79             // version codes get multiplied by 10 and an ABI suffix gets added to the code
     80             // if 'splitApk' property is set
     81         }
     82         google {
     83             dimension "distributionChannel"
     84         }
     85         nightly {
     86             dimension "distributionChannel"
     87             applicationIdSuffix ".nightly"
     88             versionCode versionCodeEpoch()
     89             versionNameSuffix " ($gitCommit)"
     90         }
     91     }
     92 
     93     compileOptions {
     94         sourceCompatibility = JavaVersion.VERSION_17
     95         targetCompatibility = JavaVersion.VERSION_17
     96 
     97         // Flag to enable support for the new language APIs for zxing
     98         coreLibraryDesugaringEnabled true
     99     }
    100 
    101     kotlinOptions {
    102         jvmTarget = "17"
    103     }
    104 
    105     buildFeatures {
    106         buildConfig true
    107         viewBinding true
    108     }
    109     packagingOptions {
    110         jniLibs {
    111             keepDebugSymbols += ['**/*.so']
    112             useLegacyPackaging true
    113         }
    114         resources {
    115             excludes += ['META-INF/*.kotlin_module']
    116         }
    117     }
    118     splits {
    119         abi {
    120             // can not be defined per flavor, so we use a property to turn this on for F-Droid
    121             enable project.hasProperty('splitApk')
    122             reset() // Resets the list of ABIs to remove all included by default
    123             include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
    124             universalApk false
    125         }
    126     }
    127 
    128     lint {
    129         abortOnError true
    130         ignoreWarnings false
    131     }
    132 }
    133 
    134 dependencies {
    135     implementation project(":taler-kotlin-android")
    136 
    137     implementation "net.taler:qtart:$qtart_version@aar"
    138 
    139     implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    140 
    141     implementation 'androidx.preference:preference-ktx:1.2.1'
    142     implementation "com.google.android.material:material:$material_version"
    143     implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
    144     implementation "androidx.browser:browser:1.10.0"
    145     implementation "androidx.biometric:biometric-ktx:1.4.0-alpha02"
    146 
    147     // Compose
    148     implementation platform('androidx.compose:compose-bom:2026.05.01')
    149     implementation 'androidx.compose.material3:material3:1.5.0-alpha21'
    150     implementation 'androidx.compose.material:material-icons-extended'
    151     implementation "androidx.compose.runtime:runtime-livedata"
    152     implementation "androidx.lifecycle:lifecycle-viewmodel-compose"
    153     implementation "com.google.accompanist:accompanist-themeadapter-material3:0.36.0"
    154     implementation 'androidx.activity:activity-compose:1.13.0'
    155     implementation 'androidx.compose.ui:ui-tooling-preview'
    156     implementation 'androidx.compose.ui:ui-viewbinding'
    157     implementation "androidx.fragment:fragment-compose:1.8.9"
    158     debugImplementation 'androidx.compose.ui:ui-tooling'
    159 
    160     // Lists and Selection
    161     implementation "androidx.recyclerview:recyclerview:1.4.0"
    162     implementation "androidx.recyclerview:recyclerview-selection:1.2.0"
    163 
    164     // Navigation Library
    165     implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
    166     implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
    167     implementation "androidx.navigation:navigation-compose:$nav_version"
    168 
    169     // ViewModel and LiveData
    170     implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    171 
    172     // CameraX for QR scanning
    173     implementation "androidx.camera:camera-camera2:1.5.3"
    174     implementation "androidx.camera:camera-lifecycle:1.5.3"
    175     implementation "androidx.camera:camera-view:1.5.3"
    176 
    177     // Core library desugaring for java.time APIs on older devices
    178     coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
    179 
    180     // Nicer ProgressBar
    181     implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'
    182 
    183     // Markdown rendering
    184     final def markdown_version = "0.43.0"
    185     implementation("com.mikepenz:multiplatform-markdown-renderer:$markdown_version")
    186     implementation("com.mikepenz:multiplatform-markdown-renderer-m3:$markdown_version")
    187 
    188     // Java Native Access (must always match JNA in qtart)
    189     implementation "net.java.dev.jna:jna:5.18.1@aar"
    190 
    191     // Shared preferences
    192     implementation "androidx.datastore:datastore:$datastore_version"
    193     implementation  "com.google.protobuf:protobuf-javalite:4.34.1"
    194 
    195     testImplementation "junit:junit:$junit_version"
    196     testImplementation 'org.json:json:20251224'
    197 
    198     // Only the "sim" build type has instrumented tests;
    199     androidTestSimImplementation "junit:junit:$junit_version"
    200     androidTestSimImplementation "androidx.test:runner:1.7.0"
    201     androidTestSimImplementation "androidx.test.ext:junit:1.3.0"
    202 }
    203 
    204 tasks.withType(KotlinCompile).configureEach {
    205     compilerOptions {
    206         freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn")
    207     }
    208 }
    209 
    210 // Map for the version code that gives each ABI a value.
    211 ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4]
    212 // For each APK output variant, override versionCode with a combination of ext.abiCodes + variant.versionCode.
    213 android.applicationVariants.configureEach { variant ->
    214     // Assigns a different version code for each output APK
    215     variant.outputs.each { output ->
    216         // Stores the value of ext.abiCodes that is associated with the ABI for this variant.
    217         def baseAbiVersionCode =
    218                 // Determines the ABI for this variant and returns the mapped value.
    219                 project.ext.abiCodes.get(output.getFilter(com.android.build.OutputFile.ABI))
    220         if (baseAbiVersionCode != null) {
    221             output.versionCodeOverride = 10 * variant.versionCode + baseAbiVersionCode
    222         }
    223         // leaves version code alone of there's no baseAbiVersionCode
    224     }
    225 }
    226 
    227 protobuf {
    228     protoc {
    229         artifact = "com.google.protobuf:protoc:4.28.3"
    230     }
    231 
    232     generateProtoTasks {
    233         all().each { task ->
    234             task.builtins {
    235                 java {
    236                     option 'lite'
    237                 }
    238             }
    239         }
    240     }
    241 }