Make minSdkVersion of GlobalSyntheticsMergeTask consistent wit others

Bug: 257488927
Test: GlobalSyntheticsTest
Change-Id: I79ac3ef95121378b3111bb01d0d45d92b101aee8
diff --git a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/tasks/GlobalSyntheticsMergeTask.kt b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/tasks/GlobalSyntheticsMergeTask.kt
index e685ef7..fdd9f55 100644
--- a/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/tasks/GlobalSyntheticsMergeTask.kt
+++ b/build-system/gradle-core/src/main/java/com/android/build/gradle/internal/tasks/GlobalSyntheticsMergeTask.kt
@@ -90,7 +90,8 @@
             super.configure(task)
             task.sharedParams.apply {
                 dexingType.setDisallowChanges(DexingType.NATIVE_MULTIDEX)
-                minSdkVersion.setDisallowChanges(creationConfig.minSdkVersion.getFeatureLevel())
+                minSdkVersion.setDisallowChanges(
+                        creationConfig.dexingCreationConfig.minSdkVersionForDexing.getFeatureLevel())
                 debuggable.setDisallowChanges(creationConfig.debuggable)
                 errorFormatMode.setDisallowChanges(SyncOptions.ErrorFormatMode.HUMAN_READABLE)
             }
diff --git a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/dexing/GlobalSyntheticsTest.kt b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/dexing/GlobalSyntheticsTest.kt
index 2b0aba6..33e2f54 100644
--- a/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/dexing/GlobalSyntheticsTest.kt
+++ b/build-system/integration-test/application/src/test/java/com/android/build/gradle/integration/dexing/GlobalSyntheticsTest.kt
@@ -23,10 +23,12 @@
 import com.android.build.gradle.internal.scope.InternalArtifactType
 import com.android.build.gradle.internal.scope.getOutputDir
 import com.android.build.gradle.options.BooleanOption
+import com.android.build.gradle.options.IntegerOption
 import com.android.testutils.MavenRepoGenerator
 import com.android.testutils.apk.AndroidArchive
 import com.google.common.io.Resources
 import com.google.common.truth.Truth
+import org.junit.Assume
 import org.junit.Before
 import org.junit.Rule
 import org.junit.Test
@@ -209,6 +211,16 @@
         checkPackagedGlobal(exceptionGlobalDex, 0)
     }
 
+    // Regression test for b/257488927
+    @Test
+    fun minSdkVersionConsistent() {
+        Assume.assumeTrue(dexType == DexType.NATIVE)
+        addFileDependencies(app)
+        executor()
+                .with(IntegerOption.IDE_TARGET_DEVICE_API, 24)
+                .run("assembleDebug")
+    }
+
     private fun createExceptionGlobalSourceFile(source: File, pkg: String, name: String) {
         source.let {
             it.parentFile.mkdirs()