plugins { id 'com.android.application' id 'org.jetbrains.kotlin.plugin.serialization' id 'org.jetbrains.kotlin.android' id 'kotlin-parcelize' alias(libs.plugins.jetbrains.compose) alias(libs.plugins.license) id 'androidx.baselineprofile' alias(libs.plugins.android.emulator) } //As Per https://developer.android.com/studio/publish/app-signing.html#release-mode def keyStoreFile = System.getenv("KEYSTORE") if(keyStoreFile == null) { keyStoreFile = "keystore.properties" } def keyStorePropertiesExists = rootProject.file(keyStoreFile).exists() def keystoreProperties = new Properties() if (keyStorePropertiesExists) { keystoreProperties.load(new FileInputStream(rootProject.file(keyStoreFile))) } configurations.all { exclude group: "net.sf.kxml", module: "kxml2" exclude group: "org.json", module: "json" /* * mockito-android's transient dependency objensis v2.7+ causes R8 to fail. * See * https://stackoverflow.com/questions/63612606/com-android-tools-r8-errors-a-methodhandle-invoke-and-methodhandle-invokeexact */ resolutionStrategy.force 'org.objenesis:objenesis:2.6' } android { buildFeatures { dataBinding false } /** * APK splitting would interfere with sideloading the app between different targets and the size * and size reduction will be minimal * * Official docs: * https://developer.android.com/guide/app-bundle/configure-base#groovy * * Source code for config options: * https://android.googlesource.com/platform/tools/base/+/studio-master-dev/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/dsl/BundleOptions.kt * * FAQ on handling side-loading: * https://developer.android.com/guide/app-bundle/faq#does_the_aab_prevent_users_from_sideloading_apps */ bundle { //This is not in the main doc, but is in the source code. texture { enableSplit = false } language { enableSplit = false } density { enableSplit = false } abi { enableSplit = false } } kotlinOptions { // Setup the Kotlin compiler options for the 'main' compilation: jvmTarget = "$version_kotlin_jvmTarget" freeCompilerArgs += "-Xopt-in=kotlinx.serialization.InternalSerializationApi" } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 coreLibraryDesugaringEnabled true } testOptions { execution 'ANDROIDX_TEST_ORCHESTRATOR' animationsDisabled true unitTests { includeAndroidResources = true returnDefaultValues = true } } if(keyStorePropertiesExists) { signingConfigs { release { keyAlias keyStorePropertiesExists ? keystoreProperties['keyAlias'] : "default" keyPassword keyStorePropertiesExists ? keystoreProperties['keyPassword'] : "default" storeFile keyStorePropertiesExists ? file(keystoreProperties['storeFile']) : new File("keystore.ks") storePassword keyStorePropertiesExists ? keystoreProperties['storePassword'] : "default" } } } compileSdk rootProject.ext.version_android_compile_sdk defaultConfig { applicationId 'org.street_child.edubridge' testInstrumentationRunnerArguments clearPackageData: 'true', notAnnotation: 'com.ustadmobile.test.core.annotation.PeerServerRequiredTest,com.ustadmobile.test.core.annotation.ImplementationRequiredTest' manifestPlaceholders = [ "presetLocale" : rootProject.ext.buildConfigProperties.getProperty("com.ustadmobile.presetlocale"), "uiLanguages": rootProject.ext.buildConfigProperties.getProperty("com.ustadmobile.uilanguages"), "showPoweredByMsg": rootProject.ext.buildConfigProperties.getProperty("com.ustadmobile.showpoweredbymsg"), "gopts": rootProject.ext.buildConfigProperties.getProperty("com.ustadmobile.gopts"), "apiUrl": rootProject.ext.buildConfigProperties.getProperty("com.ustadmobile.apiurl"), ] //When using variables the build analyzer reports that major tasks reran because of a // 'chnage' in the value of minSdkVersion, hence hardcoding them here. minSdkVersion 21 targetSdkVersion rootProject.ext.version_android_target_sdk versionCode rootProject.ext.ustadVersionCode versionName rootProject.ext.ustadVersion resourceConfigurations += ['en', 'fa', 'ps', 'ar', 'tg', 'bn', 'ne', 'my', 'ru', 'tl', 'rw'] //Shrinks minified version: remove jetpack etc. strings for unsupported locales. multiDexEnabled true //required for all variants to use java library desugaring vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" buildConfigField "String", "TEST_HOST", "\"" + rootProject.ext.buildConfigProperties["test.um_http_testserver"] + "\"" buildConfigField "String", "TEST_PORT", "\"" + rootProject.ext.buildConfigProperties["test.um_http_testserver_controlport"] + "\"" buildConfigField "String", "ACRA_HTTP_URI", "\"" + rootProject.ext.buildConfigProperties["android.acra.url"] + "\"" buildConfigField "String", "ACRA_BASIC_LOGIN", "\"" + rootProject.ext.buildConfigProperties["android.acra.user"] + "\"" buildConfigField "String", "ACRA_BASIC_PASS", "\"" + rootProject.ext.buildConfigProperties["android.acra.auth"] + "\"" //see https://proandroiddev.com/current-issues-with-kotlin-multiplatform-and-how-to-fix-them-5ae62822a546 packagingOptions { pickFirst "META-INF/io.netty.versions.properties" excludes += [ 'META-INF/INDEX.LIST', "**/*.kotlin_metadata", "META-INF/*.kotlin_module", "META-INF/versions/9/previous-compilation-data.bin" ] } } buildTypes { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' if(keyStorePropertiesExists) { signingConfig signingConfigs.release } } debug { minifyEnabled false enableUnitTestCoverage false enableAndroidTestCoverage false } } namespace 'com.toughra.ustadmobile' //See Compose to Kotlin Compatibility Map // https://developer.android.com/jetpack/androidx/releases/compose-kotlin composeOptions { kotlinCompilerExtensionVersion = "1.5.3" } packagingOptions { resources { excludes += '/META-INF/{AL2.0,LGPL2.1}' } } compileOptions { sourceCompatibility JavaVersion.VERSION_17 targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = '17' } } /* * Android Emulator plugin will start the emulator required for baseline profile generation */ androidEmulator { emulator { sdkVersion 33 abi 'x86_64' includeGoogleApis false } enableForAndroidTests true headless true } configurations.all { /** * As per Door room-annotations module README: exclude the room-annotations module to avoid * duplicate class error */ exclude group: "com.github.UstadMobile.door", module: "room-annotations" } dependencies { implementation libs.androidx.profileinstaller baselineProfile project(':app-android-baselineprofile') coreLibraryDesugaring libs.android.desugar.libs implementation project(':core') implementation project(':sharedse') implementation project(':lib-ui-compose') implementation project(":lib-cache") implementation libs.door.runtime implementation project(':lib-database') implementation project(':lib-util') api libs.moko.resources api libs.moko.resources.compose implementation libs.napier implementation libs.androidx.activity implementation libs.androidx.activity.ktx implementation libs.androidx.fragment implementation libs.androidx.legacy.support.v4 implementation libs.kotlinx.serialization implementation libs.kotlinx.coroutines.android implementation libs.commons.io //ViewModel and LiveData implementation libs.androidx.lifecycle.livedata.ktx implementation libs.androidx.lifecycle.runtime.ktx implementation libs.androidx.lifecycle.common.java8 //Provides ProcessLifecycleOwner implementation libs.androidx.lifecycle.process // Room (annotation processing takes place only on lib-database to improve build times) implementation libs.androidx.room.runtime implementation libs.androidx.core.ktx // Paging implementation(libs.androidx.paging.runtime) implementation(libs.androidx.paging.compose) implementation libs.androidx.annotation //Work manager implementation libs.androidx.work.runtime //Klock implementation libs.klock.android //Crash reporting implementation libs.acra.http //DataStore implementation libs.androidx.datastore.preferences implementation libs.androidx.legacy.core.utils implementation libs.androidx.appcompat implementation libs.android.material implementation libs.androidx.legacy.support.v4 implementation libs.androidx.recyclerview //Compose implementation platform(libs.androidx.compose.bom) implementation libs.androidx.compose.material implementation libs.androidx.compose.ui.tooling.preview debugImplementation libs.androidx.compose.ui.tooling implementation libs.activity.compose implementation libs.androidx.window implementation libs.androidx.compose.material.icons.extended implementation libs.androidx.compose.material3.window.size.clazz implementation libs.accompanist.themeadapter.material implementation libs.accompanist.pager implementation libs.accompanist.pager.indicators implementation libs.reorderable.compose implementation libs.accompanist.flowlayout //Image loading library implementation libs.picasso //KTOR implementation libs.ktor.client.okhttp implementation libs.ktor.client.content.negotiation //http server implementation libs.nanohttpd implementation libs.nanohttpd.nanolets implementation libs.androidx.navigation.fragment.ktx implementation libs.androidx.navigation.ui implementation libs.androidx.navigation.ui.ktx //dependency injection implementation libs.kodein.di.framework.android.x implementation libs.dragdropswiperecyclerview //PanicKit (PanicButton) integration implementation libs.guardianproject.panic //Image loading implementation libs.coil implementation libs.coil.compose implementation libs.kotlinx.datetime //Xml processing implementation libs.xmlutil.core implementation libs.xmlutil.serialization implementation libs.multiplatformsettings implementation libs.process.phoenix implementation libs.androidx.browser implementation libs.androidx.core.splashscreen implementation libs.rawhttp.core androidTestImplementation libs.androidx.test.runner androidTestImplementation libs.junit androidTestImplementation libs.androidx.test.core androidTestUtil libs.androidx.test.orchestrator } licenseReport { generateHtmlReport = true copyHtmlReportToAssets = true }