Merge "Turn on the instrumentation by default for the java code in APEXes"
diff --git a/java/java.go b/java/java.go
index ceedd89..41fd8da 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1510,6 +1510,11 @@
 		j.headerJarFile = j.implementationJarFile
 	}
 
+	// Force enable the instrumentation for java code that is built for APEXes
+	if android.DirectlyInAnyApex(ctx, ctx.ModuleName()) && !j.IsForPlatform() {
+		j.properties.Instrument = true
+	}
+
 	if j.shouldInstrument(ctx) {
 		outputFile = j.instrument(ctx, flags, outputFile, jarName)
 	}