@file:Suppress("UnstableApiUsage") import com.android.build.api.dsl.ManagedVirtualDevice plugins { alias(libs.plugins.com.android.test) alias(libs.plugins.org.jetbrains.kotlin.android) } android { namespace = "com.m3u.benchmark" compileSdk = 34 compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 } kotlinOptions { jvmTarget = "17" } defaultConfig { minSdk = 26 targetSdk = 33 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } flavorDimensions += setOf("channel", "codec") productFlavors { create("stableChannel") { dimension = "channel" } create("snapshotChannel") { dimension = "channel" } create("richCodec") { dimension = "codec" } create("liteCodec") { dimension = "codec" } } testOptions { managedDevices { allDevices { // Add Gradle task // :benchmark:Pixel5Api31BenchmarkAndroidTest --rerun-tasks -P // android.testInstrumentationRunnerArguments.class=com.m3u.benchmark.BaselineProfileGenerator create("Pixel5Api31", ManagedVirtualDevice::class) { device = "Pixel 5" apiLevel = 31 systemImageSource = "aosp" } } } } buildTypes { // This benchmark buildType is used for benchmarking, and should function like your // release build (for example, with minification on). It"s signed with a debug key // for easy local/CI testing. create("benchmark") { isDebuggable = true signingConfig = getByName("debug").signingConfig matchingFallbacks += listOf("release") } } targetProjectPath = ":androidApp" experimentalProperties["android.experimental.self-instrumenting"] = true } dependencies { implementation(libs.androidx.test.ext.junit) implementation(libs.androidx.test.espresso.espresso.core) implementation(libs.androidx.test.uiautomator.uiautomator) implementation(libs.androidx.benchmark.benchmark.macro.junit4) } androidComponents { beforeVariants(selector().all()) { it.enable = it.buildType == "benchmark" } }