Bug 40123: Allow building the instrumented tests apks for variants other than debug

This allows to specify the variant of the instrumented tests via
a `testBuildType` gradle argument. It also applies a workaround for
a R8 issue from https://issuetracker.google.com/issues/140851070.
latest
Status Job ID Name Coverage
  Build
failed #8591
32GB
buildDebug

 
  Test
skipped #8592
32GB
testLight
 
Name Stage Failure
failed
buildDebug Build There has been a timeout failure or the job got stuck. Check your timeout limits or try again
No job log