IMPORTANT: The file content has been truncated. Status: Showing lines 120-250 of 569 total lines. Action: To read more of the file, you can use the 'start_line' and 'end_line' parameters in a subsequent 'read_file' call. For example, to read the next section of the file, use start_line: 251. --- FILE CONTENT (truncated) --- } packaging { resources { excludes += "/META-INF/{AL2.0,LGPL2.1}" excludes += "META-INF/LICENSE.md" excludes += "META-INF/LICENSE-notice.md" } } testOptions { unitTests { isIncludeAndroidResources = true } managedDevices { allDevices { create("pixel2api33") { device = "Pixel 2" apiLevel = 33 systemImageSource = "aosp" testedAbi = "x86_64" } create("phonePixel6api34") { device = "Pixel 6" apiLevel = 34 systemImageSource = "aosp" testedAbi = "x86_64" } create("tablet7Nexus7api34") { device = "Nexus 7" apiLevel = 34 systemImageSource = "aosp" testedAbi = "x86_64" } create("tablet10PixelTabletApi34") { device = "Pixel Tablet" apiLevel = 34 systemImageSource = "aosp" testedAbi = "x86_64" } } } } lint { abortOnError = true warningsAsErrors = false xmlReport = true htmlReport = true baseline = file("lint-baseline.xml") } } tasks.withType().configureEach { compilerOptions { jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) } } detekt { config.setFrom(rootProject.file("config/detekt/detekt.yml")) buildUponDefaultConfig = true autoCorrect = true } tasks.named("check") { dependsOn("lintDebug") } afterEvaluate { // Note: This reflective block and the use of afterEvaluate make the build incompatible with // the Configuration Cache (CC) for managed device test tasks. ManagedDeviceInstrumentationTestTask // cannot be serialized when configured reflectively in afterEvaluate. We accept this trade-off // to enable per-device instrumentation arguments which AGP 8.x does not yet expose via a public DSL. tasks.withType().configureEach { val deviceDirName = when { name.contains("phonePixel6api34", ignoreCase = true) -> "phonePixel6api34" name.contains("tablet7Nexus7api34", ignoreCase = true) -> "tablet7Nexus7api34" name.contains("tablet10PixelTabletApi34", ignoreCase = true) -> "tablet10PixelTabletApi34" name.contains("pixel2api33", ignoreCase = true) -> "pixel2api33" else -> null } if (deviceDirName != null) { // Set the host-side directory where GMD will pull files from. getAdditionalTestOutputDir().set( layout.buildDirectory.dir("outputs/managed_device_android_test_additional_output/$testVariant/$deviceDirName"), ) } // AGP does not provide a public DSL to set per-ManagedVirtualDevice instrumentation arguments. // We use reflection to reach into the internal testData property and its instrumentationRunnerArguments map. val getTestDataMethod = javaClass.getMethod("getTestData") val testDataProperty = getTestDataMethod.invoke(this) as org.gradle.api.provider.Property<*> val testData = testDataProperty.get() val getArgsMethod = testData.javaClass.getMethod("getInstrumentationRunnerArguments") @Suppress("UNCHECKED_CAST") val argsProperty = getArgsMethod.invoke(testData) as org.gradle.api.provider.MapProperty // Use putAll(provider) to ensure that the arguments are evaluated specifically for this task instance. // This prevents aliasing/merging issues when AGP shares the underlying property object across tasks. val taskName = name argsProperty.putAll( provider { val map = mutableMapOf() when { taskName.contains("phonePixel6api34", ignoreCase = true) -> { map["package"] = screenshotTestPackage map["additionalTestOutputDir"] = "/sdcard/test-outputs/screenshots" } taskName.contains("tablet7Nexus7api34", ignoreCase = true) -> { map["package"] = screenshotTestPackage map["additionalTestOutputDir"] = "/sdcard/test-outputs/screenshots" } taskName.contains("tablet10PixelTabletApi34", ignoreCase = true) -> { map["package"] = screenshotTestPackage map["additionalTestOutputDir"] = "/sdcard/test-outputs/screenshots" } taskName.contains("pixel2api33", ignoreCase = true) -> { map["notPackage"] = screenshotTestPackage map["additionalTestOutputDir"] = "/sdcard/test-outputs/smoke" } } map }, ) } } tasks.register("generateGmdCoverage") {