build.gradle (9901B)
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 // Unit-test coverage, so that contrib/ci/jobs/5-coverage can 64 // report this module on lcov.taler.net. Costs nothing when the 65 // tests are not run. 66 enableUnitTestCoverage true 67 } 68 // Build type for simulator/, the emulator-driven exploration harness. 69 // Same application id as debug (so the simulator drives the same 70 // package a developer would install), plus JaCoCo instrumentation and 71 // the debug-only hooks in src/sim. Never published. 72 sim { 73 initWith debug 74 signingConfig signingConfigs.debug 75 minifyEnabled false 76 enableAndroidTestCoverage true 77 // Inherited from debug through initWith, and spelled out because 78 // the coverage report depends on it: the emulator is not the only 79 // thing that covers this app, and JaCoCo can only merge execution 80 // data with the *same* class files behind it. Reporting the 81 // simulator's .ec files and the JVM unit tests together therefore 82 // means both have to come from this build type, which is why 83 // contrib/ci/jobs/5-coverage runs :wallet:testFdroidSimUnitTest 84 // rather than the fdroidDebug one. 85 enableUnitTestCoverage true 86 matchingFallbacks = ['debug'] 87 } 88 } 89 flavorDimensions = ["distributionChannel"] 90 productFlavors { 91 fdroid { 92 dimension "distributionChannel" 93 applicationIdSuffix ".fdroid" 94 // version codes get multiplied by 10 and an ABI suffix gets added to the code 95 // if 'splitApk' property is set 96 } 97 google { 98 dimension "distributionChannel" 99 } 100 nightly { 101 dimension "distributionChannel" 102 applicationIdSuffix ".nightly" 103 versionCode versionCodeEpoch() 104 versionNameSuffix " ($gitCommit)" 105 } 106 } 107 108 compileOptions { 109 sourceCompatibility = JavaVersion.VERSION_17 110 targetCompatibility = JavaVersion.VERSION_17 111 112 // Flag to enable support for the new language APIs for zxing 113 coreLibraryDesugaringEnabled true 114 } 115 116 kotlinOptions { 117 jvmTarget = "17" 118 } 119 120 buildFeatures { 121 buildConfig true 122 viewBinding true 123 } 124 packagingOptions { 125 jniLibs { 126 keepDebugSymbols += ['**/*.so'] 127 useLegacyPackaging true 128 } 129 resources { 130 excludes += ['META-INF/*.kotlin_module'] 131 } 132 } 133 splits { 134 abi { 135 // can not be defined per flavor, so we use a property to turn this on for F-Droid 136 enable project.hasProperty('splitApk') 137 reset() // Resets the list of ABIs to remove all included by default 138 include "armeabi-v7a", "arm64-v8a", "x86", "x86_64" 139 universalApk false 140 } 141 } 142 143 lint { 144 abortOnError true 145 ignoreWarnings false 146 } 147 } 148 149 dependencies { 150 implementation project(":taler-kotlin-android") 151 152 implementation "net.taler:qtart:$qtart_version@aar" 153 154 implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version" 155 156 implementation 'androidx.preference:preference-ktx:1.2.1' 157 implementation "com.google.android.material:material:$material_version" 158 implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version" 159 implementation "androidx.browser:browser:1.10.0" 160 implementation "androidx.biometric:biometric-ktx:1.4.0-alpha02" 161 162 // Compose 163 implementation platform('androidx.compose:compose-bom:2026.05.01') 164 implementation 'androidx.compose.material3:material3:1.5.0-alpha21' 165 implementation 'androidx.compose.material:material-icons-extended' 166 implementation "androidx.compose.runtime:runtime-livedata" 167 implementation "androidx.lifecycle:lifecycle-viewmodel-compose" 168 implementation "com.google.accompanist:accompanist-themeadapter-material3:0.36.0" 169 implementation 'androidx.activity:activity-compose:1.13.0' 170 implementation 'androidx.compose.ui:ui-tooling-preview' 171 implementation 'androidx.compose.ui:ui-viewbinding' 172 implementation "androidx.fragment:fragment-compose:1.8.9" 173 debugImplementation 'androidx.compose.ui:ui-tooling' 174 175 // Lists and Selection 176 implementation "androidx.recyclerview:recyclerview:1.4.0" 177 implementation "androidx.recyclerview:recyclerview-selection:1.2.0" 178 179 // Navigation Library 180 implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" 181 implementation "androidx.navigation:navigation-ui-ktx:$nav_version" 182 implementation "androidx.navigation:navigation-compose:$nav_version" 183 184 // ViewModel and LiveData 185 implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version" 186 187 // CameraX for QR scanning 188 implementation "androidx.camera:camera-camera2:1.5.3" 189 implementation "androidx.camera:camera-lifecycle:1.5.3" 190 implementation "androidx.camera:camera-view:1.5.3" 191 192 // Core library desugaring for java.time APIs on older devices 193 coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5' 194 195 // Nicer ProgressBar 196 implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1' 197 198 // Markdown rendering 199 final def markdown_version = "0.43.0" 200 implementation("com.mikepenz:multiplatform-markdown-renderer:$markdown_version") 201 implementation("com.mikepenz:multiplatform-markdown-renderer-m3:$markdown_version") 202 203 // Java Native Access (must always match JNA in qtart) 204 implementation "net.java.dev.jna:jna:5.18.1@aar" 205 206 // Shared preferences 207 implementation "androidx.datastore:datastore:$datastore_version" 208 implementation "com.google.protobuf:protobuf-javalite:4.34.1" 209 210 testImplementation "junit:junit:$junit_version" 211 testImplementation 'org.json:json:20251224' 212 213 // Only the "sim" build type has instrumented tests; see 214 // src/androidTestSim and simulator/README.md. They exist so that AGP 215 // creates an androidTest variant, which is what makes 216 // enableAndroidTestCoverage instrument the app's classes. 217 androidTestSimImplementation "junit:junit:$junit_version" 218 androidTestSimImplementation "androidx.test:runner:1.7.0" 219 androidTestSimImplementation "androidx.test.ext:junit:1.3.0" 220 } 221 222 tasks.withType(KotlinCompile).configureEach { 223 compilerOptions { 224 freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn") 225 } 226 } 227 228 // Map for the version code that gives each ABI a value. 229 ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, x86: 3, x86_64: 4] 230 // For each APK output variant, override versionCode with a combination of ext.abiCodes + variant.versionCode. 231 android.applicationVariants.configureEach { variant -> 232 // Assigns a different version code for each output APK 233 variant.outputs.each { output -> 234 // Stores the value of ext.abiCodes that is associated with the ABI for this variant. 235 def baseAbiVersionCode = 236 // Determines the ABI for this variant and returns the mapped value. 237 project.ext.abiCodes.get(output.getFilter(com.android.build.OutputFile.ABI)) 238 if (baseAbiVersionCode != null) { 239 output.versionCodeOverride = 10 * variant.versionCode + baseAbiVersionCode 240 } 241 // leaves version code alone of there's no baseAbiVersionCode 242 } 243 } 244 245 protobuf { 246 protoc { 247 artifact = "com.google.protobuf:protoc:4.28.3" 248 } 249 250 generateProtoTasks { 251 all().each { task -> 252 task.builtins { 253 java { 254 option 'lite' 255 } 256 } 257 } 258 } 259 }