For run_on_as_app, use r8 jar to find version and not Version.java

Change-Id: I38dd0b4b72cce0f4a7956f1b4d4868ab0a88bcf5
diff --git a/tools/archive.py b/tools/archive.py
index ecc0c04..c842c69 100755
--- a/tools/archive.py
+++ b/tools/archive.py
@@ -26,6 +26,7 @@
   return result.parse_args()
 
 def GetToolVersion(jar_path):
+  # TODO(mkroghj) This would not work for r8-lib, maybe use utils.getR8Version.
   output = subprocess.check_output([
     jdk.GetJavaExecutable(), '-jar', jar_path, '--version'
   ])
diff --git a/tools/run_on_as_app.py b/tools/run_on_as_app.py
index fef337a..d95453f 100755
--- a/tools/run_on_as_app.py
+++ b/tools/run_on_as_app.py
@@ -198,12 +198,15 @@
   assert len(lines) >= 1
   return lines[-1]
 
-def CheckIsBuiltWithExpectedR8(apk, temp_dir, options):
+def CheckIsBuiltWithExpectedR8(apk, temp_dir, shrinker, options):
   marker = ExtractMarker(apk, temp_dir, options)
   expected_version = (
       options.version
       if options.version
-      else create_maven_release.determine_version())
+      else utils.getR8Version(
+          os.path.join(
+              temp_dir,
+              'r8lib.jar' if IsMinifiedR8(shrinker) else 'r8.jar')))
   if marker.startswith('~~R8'):
     actual_version = json.loads(marker[4:]).get('version')
     if actual_version == expected_version:
@@ -509,7 +512,7 @@
     as_utils.MoveFile(unsigned_apk, apk_dest, quiet=options.quiet)
 
   assert ('r8' not in shrinker
-      or CheckIsBuiltWithExpectedR8(apk_dest, temp_dir, options))
+      or CheckIsBuiltWithExpectedR8(apk_dest, temp_dir, shrinker, options))
 
   profile_dest_dir = os.path.join(out_dir, 'profile')
   as_utils.MoveProfileReportTo(profile_dest_dir, stdout, quiet=options.quiet)
diff --git a/tools/utils.py b/tools/utils.py
index 13b61cf..8c168a6 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -496,3 +496,10 @@
 
 def uncompressed_size(path):
   return sum(z.file_size for z in zipfile.ZipFile(path).infolist())
+
+def getR8Version(path):
+  cmd = [jdk.GetJavaExecutable(), '-cp', path, 'com.android.tools.r8.R8',
+        '--version']
+  output = subprocess.check_output(cmd, stderr = subprocess.STDOUT)
+  # output is on form 'R8 <version>' so we just strip of 'R8 '.
+  return output.splitlines()[0][3:]