Fix pg compilation and relax r8 assertion when running run_on_as_app

Change-Id: I1562f8e43e96f342377497fdb9cfbf5acae03c06
diff --git a/tools/run_on_as_app.py b/tools/run_on_as_app.py
index 3b21ba9..53ddbe7 100755
--- a/tools/run_on_as_app.py
+++ b/tools/run_on_as_app.py
@@ -728,13 +728,14 @@
     if not options.no_build or options.golem:
       gradle.RunGradle(['r8', 'r8lib'])
 
-    assert os.path.isfile(utils.R8_JAR), 'Cannot build without r8.jar'
-    assert os.path.isfile(utils.R8LIB_JAR), 'Cannot build without r8lib.jar'
-
     # Make a copy of r8.jar and r8lib.jar such that they stay the same for
     # the entire execution of this script.
-    shutil.copyfile(utils.R8_JAR, os.path.join(temp_dir, 'r8.jar'))
-    shutil.copyfile(utils.R8LIB_JAR, os.path.join(temp_dir, 'r8lib.jar'))
+    if 'r8-nolib' in options.shrinker:
+      assert os.path.isfile(utils.R8_JAR), 'Cannot build without r8.jar'
+      shutil.copyfile(utils.R8_JAR, os.path.join(temp_dir, 'r8.jar'))
+    if 'r8' in options.shrinker:
+      assert os.path.isfile(utils.R8LIB_JAR), 'Cannot build without r8lib.jar'
+      shutil.copyfile(utils.R8LIB_JAR, os.path.join(temp_dir, 'r8lib.jar'))
 
     result_per_shrinker_per_app = {}