Revert "Revert "R8/D8 should use sdk_version prop to determine API surface stability.""

This reverts commit 7eb9243fa78189000da9d5beeabaea3b8b2c0fd5.

Reason for revert: The original change was reverted since it was suspected to cause missing libc++.so errors. It was a red herring, and the root cause has been fixed now b/264588525

Change-Id: Ib9110c41bacf220b91f24de11589f63235895e56
diff --git a/java/java.go b/java/java.go
index b3abc91..1e8d7b9 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1981,7 +1981,15 @@
 			j.dexpreopter.uncompressedDex = *j.dexProperties.Uncompress_dex
 
 			var dexOutputFile android.OutputPath
-			dexOutputFile = j.dexer.compileDex(ctx, flags, j.MinSdkVersion(ctx), outputFile, jarName)
+			dexParams := &compileDexParams{
+				flags:         flags,
+				sdkVersion:    j.SdkVersion(ctx),
+				minSdkVersion: j.MinSdkVersion(ctx),
+				classesJar:    outputFile,
+				jarName:       jarName,
+			}
+
+			dexOutputFile = j.dexer.compileDex(ctx, dexParams)
 			if ctx.Failed() {
 				return
 			}