Report compiler error on deprecated uses of main-dex-list

Bug: b/181858113
Change-Id: I4700d34e7853182c1df169e1ba42065d58a97d65
diff --git a/src/main/java/com/android/tools/r8/dex/ApplicationReader.java b/src/main/java/com/android/tools/r8/dex/ApplicationReader.java
index 04ff802..5e31c47 100644
--- a/src/main/java/com/android/tools/r8/dex/ApplicationReader.java
+++ b/src/main/java/com/android/tools/r8/dex/ApplicationReader.java
@@ -189,13 +189,13 @@
     if (inputApp.hasMainDexList()) {
       for (StringResource resource : inputApp.getMainDexListResources()) {
         if (emitDeprecatedDiagnostics) {
-          options.reporter.warning(new UnsupportedMainDexListUsageDiagnostic(resource.getOrigin()));
+          options.reporter.error(new UnsupportedMainDexListUsageDiagnostic(resource.getOrigin()));
         }
         addToMainDexClasses(app, builder, MainDexListParser.parseList(resource, itemFactory));
       }
       if (!inputApp.getMainDexClasses().isEmpty()) {
         if (emitDeprecatedDiagnostics) {
-          options.reporter.warning(new UnsupportedMainDexListUsageDiagnostic(Origin.unknown()));
+          options.reporter.error(new UnsupportedMainDexListUsageDiagnostic(Origin.unknown()));
         }
         addToMainDexClasses(
             app,
diff --git a/src/test/java/com/android/tools/r8/classmerging/horizontal/PreventMergeMainDexListTest.java b/src/test/java/com/android/tools/r8/classmerging/horizontal/PreventMergeMainDexListTest.java
index 11a96b7..250a8e9 100644
--- a/src/test/java/com/android/tools/r8/classmerging/horizontal/PreventMergeMainDexListTest.java
+++ b/src/test/java/com/android/tools/r8/classmerging/horizontal/PreventMergeMainDexListTest.java
@@ -5,18 +5,13 @@
 package com.android.tools.r8.classmerging.horizontal;
 
 import static com.android.tools.r8.DiagnosticsMatcher.diagnosticType;
-import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThrows;
 
+import com.android.tools.r8.CompilationFailedException;
 import com.android.tools.r8.NeverClassInline;
-import com.android.tools.r8.OutputMode;
-import com.android.tools.r8.R8TestCompileResult;
 import com.android.tools.r8.TestParameters;
 import com.android.tools.r8.TestParametersCollection;
 import com.android.tools.r8.errors.UnsupportedMainDexListUsageDiagnostic;
-import com.android.tools.r8.utils.codeinspector.CodeInspector;
-import java.nio.file.Path;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -30,7 +25,7 @@
   @Parameterized.Parameters(name = "{0}")
   public static TestParametersCollection data() {
     return getTestParameters()
-        .withDexRuntimes()
+        .withDefaultDexRuntime()
         .withApiLevelsEndingAtExcluding(apiLevelWithNativeMultiDexSupport())
         .build();
   }
@@ -39,42 +34,23 @@
   //  Ensure the main-dex-rules variant of this test (PreventMergeMainDexTracingTest) is sufficient.
   @Test
   public void testR8() throws Exception {
-    testForR8(parameters.getBackend())
-        .addInnerClasses(getClass())
-        .addKeepClassAndMembersRules(Main.class)
-        .addMainDexListClasses(A.class, Main.class)
-        .addOptionsModification(options -> options.minimalMainDex = true)
-        .enableNeverClassInliningAnnotations()
-        .setMinApi(parameters)
-        .allowDiagnosticMessages()
-        .compileWithExpectedDiagnostics(
-            diagnostics ->
-                diagnostics
-                    .assertOnlyWarnings()
-                    .assertWarningsMatch(
-                        diagnosticType(UnsupportedMainDexListUsageDiagnostic.class)))
-        .apply(this::checkCompileResult)
-        .run(parameters.getRuntime(), Main.class)
-        .assertSuccessWithOutputLines("main dex");
-  }
-
-  private void checkCompileResult(R8TestCompileResult compileResult) throws Exception {
-    Path out = temp.newFolder().toPath();
-    compileResult.app.writeToDirectory(out, OutputMode.DexIndexed);
-    Path classes = out.resolve("classes.dex");
-    Path classes2 = out.resolve("classes2.dex");
-    inspectMainDex(new CodeInspector(classes, compileResult.getProguardMap()));
-    inspectSecondaryDex(new CodeInspector(classes2, compileResult.getProguardMap()));
-  }
-
-  private void inspectMainDex(CodeInspector inspector) {
-    assertThat(inspector.clazz(A.class), isPresent());
-    assertThat(inspector.clazz(B.class), not(isPresent()));
-  }
-
-  private void inspectSecondaryDex(CodeInspector inspector) {
-    assertThat(inspector.clazz(A.class), not(isPresent()));
-    assertThat(inspector.clazz(B.class), isPresent());
+    assertThrows(
+        CompilationFailedException.class,
+        () ->
+            testForR8(parameters.getBackend())
+                .addInnerClasses(getClass())
+                .addKeepClassAndMembersRules(Main.class)
+                .addMainDexListClasses(A.class, Main.class)
+                .addOptionsModification(options -> options.minimalMainDex = true)
+                .enableNeverClassInliningAnnotations()
+                .setMinApi(parameters)
+                .allowDiagnosticMessages()
+                .compileWithExpectedDiagnostics(
+                    diagnostics ->
+                        diagnostics
+                            .assertOnlyErrors()
+                            .assertErrorsMatch(
+                                diagnosticType(UnsupportedMainDexListUsageDiagnostic.class))));
   }
 
   public static class Main {
diff --git a/src/test/java/com/android/tools/r8/compilerapi/maindex/MainDexClassesTest.java b/src/test/java/com/android/tools/r8/compilerapi/maindex/MainDexClassesTest.java
index c24ab90..f204285 100644
--- a/src/test/java/com/android/tools/r8/compilerapi/maindex/MainDexClassesTest.java
+++ b/src/test/java/com/android/tools/r8/compilerapi/maindex/MainDexClassesTest.java
@@ -3,6 +3,8 @@
 // BSD-style license that can be found in the LICENSE file.
 package com.android.tools.r8.compilerapi.maindex;
 
+import static org.junit.Assert.fail;
+
 import com.android.tools.r8.CompilationFailedException;
 import com.android.tools.r8.D8;
 import com.android.tools.r8.D8Command;
@@ -38,10 +40,12 @@
     void run(ApiTest test, String[] mainDexClasses, DiagnosticsHandler handler) throws Exception;
   }
 
+  TestDiagnosticMessagesImpl handler;
+
   private TestDiagnosticMessagesImpl runTest(Runner runner) throws Exception {
     ApiTest test = new ApiTest(ApiTest.PARAMETERS);
     String[] mainDexClasses = new String[] {InputClass.class.getName()};
-    TestDiagnosticMessagesImpl handler = new TestDiagnosticMessagesImpl();
+    handler = new TestDiagnosticMessagesImpl();
     runner.run(test, mainDexClasses, handler);
     return handler;
   }
@@ -62,18 +66,30 @@
 
   @Test
   public void testD8CfInputs() throws Exception {
-    runTest((test, mainDexClasses, handler) -> test.runD8(getCfInput(), mainDexClasses, handler))
-        .assertOnlyWarnings()
-        .assertAllWarningsMatch(
-            DiagnosticsMatcher.diagnosticType(UnsupportedMainDexListUsageDiagnostic.class));
+    try {
+      runTest((test, mainDexClasses, handler) -> test.runD8(getCfInput(), mainDexClasses, handler));
+    } catch (CompilationFailedException e) {
+      handler
+          .assertOnlyErrors()
+          .assertAllErrorsMatch(
+              DiagnosticsMatcher.diagnosticType(UnsupportedMainDexListUsageDiagnostic.class));
+      return;
+    }
+    fail("Expected compilation failure");
   }
 
   @Test
   public void testR8() throws Exception {
-    runTest((test, mainDexClasses, handler) -> test.runR8(getCfInput(), mainDexClasses, handler))
-        .assertOnlyWarnings()
-        .assertAllWarningsMatch(
-            DiagnosticsMatcher.diagnosticType(UnsupportedMainDexListUsageDiagnostic.class));
+    try {
+      runTest((test, mainDexClasses, handler) -> test.runR8(getCfInput(), mainDexClasses, handler));
+    } catch (CompilationFailedException e) {
+      handler
+          .assertOnlyErrors()
+          .assertAllErrorsMatch(
+              DiagnosticsMatcher.diagnosticType(UnsupportedMainDexListUsageDiagnostic.class));
+      return;
+    }
+    fail("Expected compilation failure");
   }
 
   public static class ApiTest extends CompilerApiTest {
diff --git a/src/test/java/com/android/tools/r8/compilerapi/maindex/MainDexListTest.java b/src/test/java/com/android/tools/r8/compilerapi/maindex/MainDexListTest.java
index 7b2264d..47430fd 100644
--- a/src/test/java/com/android/tools/r8/compilerapi/maindex/MainDexListTest.java
+++ b/src/test/java/com/android/tools/r8/compilerapi/maindex/MainDexListTest.java
@@ -3,6 +3,8 @@
 // BSD-style license that can be found in the LICENSE file.
 package com.android.tools.r8.compilerapi.maindex;
 
+import static org.junit.Assert.fail;
+
 import com.android.tools.r8.CompilationFailedException;
 import com.android.tools.r8.D8;
 import com.android.tools.r8.D8Command;
@@ -39,12 +41,14 @@
     void run(ApiTest test, Path mainDexList, DiagnosticsHandler handler) throws Exception;
   }
 
+  TestDiagnosticMessagesImpl handler;
+
   private TestDiagnosticMessagesImpl runTest(Runner runner) throws Exception {
     ApiTest test = new ApiTest(ApiTest.PARAMETERS);
     Path mainDexListInput =
         FileUtils.writeTextFile(
             temp.newFile().toPath(), InputClass.class.getName().replace('.', '/') + ".class");
-    TestDiagnosticMessagesImpl handler = new TestDiagnosticMessagesImpl();
+    handler = new TestDiagnosticMessagesImpl();
     runner.run(test, mainDexListInput, handler);
     return handler;
   }
@@ -65,18 +69,30 @@
 
   @Test
   public void testD8CfInputs() throws Exception {
-    runTest((test, mainDexList, handler) -> test.runD8(getCfInput(), mainDexList, handler))
-        .assertOnlyWarnings()
-        .assertAllWarningsMatch(
-            DiagnosticsMatcher.diagnosticType(UnsupportedMainDexListUsageDiagnostic.class));
+    try {
+      runTest((test, mainDexList, handler) -> test.runD8(getCfInput(), mainDexList, handler));
+    } catch (CompilationFailedException e) {
+      handler
+          .assertOnlyErrors()
+          .assertAllErrorsMatch(
+              DiagnosticsMatcher.diagnosticType(UnsupportedMainDexListUsageDiagnostic.class));
+      return;
+    }
+    fail("Expected compilation failure");
   }
 
   @Test
   public void testR8() throws Exception {
-    runTest((test, mainDexList, handler) -> test.runR8(getCfInput(), mainDexList, handler))
-        .assertOnlyWarnings()
-        .assertAllWarningsMatch(
-            DiagnosticsMatcher.diagnosticType(UnsupportedMainDexListUsageDiagnostic.class));
+    try {
+      runTest((test, mainDexList, handler) -> test.runR8(getCfInput(), mainDexList, handler));
+    } catch (CompilationFailedException e) {
+      handler
+          .assertOnlyErrors()
+          .assertAllErrorsMatch(
+              DiagnosticsMatcher.diagnosticType(UnsupportedMainDexListUsageDiagnostic.class));
+      return;
+    }
+    fail("Expected compilation failure");
   }
 
   public static class ApiTest extends CompilerApiTest {
diff --git a/src/test/java/com/android/tools/r8/d8/ProguardMapSortByTest.java b/src/test/java/com/android/tools/r8/d8/ProguardMapSortByTest.java
index e7169c3..6175552 100644
--- a/src/test/java/com/android/tools/r8/d8/ProguardMapSortByTest.java
+++ b/src/test/java/com/android/tools/r8/d8/ProguardMapSortByTest.java
@@ -51,7 +51,7 @@
             .addOptionsModification(
                 internalOptions -> internalOptions.testing.limitNumberOfClassesPerDex = 2);
     if (parameters.getApiLevel().isLessThan(AndroidApiLevel.L)) {
-      d8TestBuilder.addMainDexListClasses(A.class);
+      d8TestBuilder.addMainDexRules("-keep class " + A.class.getName());
     }
     Path outputDir = temp.newFolder().toPath();
     d8TestBuilder
diff --git a/src/test/java/com/android/tools/r8/desugar/backports/BackportMainDexTest.java b/src/test/java/com/android/tools/r8/desugar/backports/BackportMainDexTest.java
index 5369238..0143e8e 100644
--- a/src/test/java/com/android/tools/r8/desugar/backports/BackportMainDexTest.java
+++ b/src/test/java/com/android/tools/r8/desugar/backports/BackportMainDexTest.java
@@ -209,12 +209,19 @@
             .compile()
             .writeToZip();
 
+    Path out3 =
+        testForD8()
+            .addProgramClasses(TestClass.class, MiniAssert.class)
+            .addClasspathClasses(CLASSES)
+            .setIntermediate(true)
+            .setMinApi(parameters)
+            .compile()
+            .writeToZip();
+
     MainDexConsumer mainDexConsumer = new MainDexConsumer();
-    List<Class<?>> classes = ImmutableList.of(TestClass.class, MiniAssert.class);
-    List<Path> files = ImmutableList.of(out1, out2);
-    GenerateMainDexListRunResult traceResult = traceMainDex(classes, files);
+    List<Path> files = ImmutableList.of(out1, out2, out3);
+    GenerateMainDexListRunResult traceResult = traceMainDex(Collections.emptyList(), files);
     testForD8()
-        .addProgramClasses(classes)
         .addProgramFiles(files)
         .setMinApi(parameters)
         .addMainDexListClassReferences(traceResult.getMainDexList())
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexApi21Test.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexApi21Test.java
index b9c3c87..551e1b0 100644
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexApi21Test.java
+++ b/src/test/java/com/android/tools/r8/maindexlist/MainDexApi21Test.java
@@ -99,7 +99,12 @@
     TestConsumer programConsumer = new TestConsumer();
     testForD8()
         .setMinApi(AndroidApiLevel.L)
-        .addProgramClasses(ImmutableList.of(TestClassA.class, TestClassB.class))
+        .addProgramFiles(
+            testForD8()
+                .addProgramClasses(TestClassA.class, TestClassB.class)
+                .setMinApi(AndroidApiLevel.L)
+                .compile()
+                .writeToZip())
         .addMainDexListClasses(TestClassB.class)
         .setProgramConsumer(programConsumer)
         .compile();
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexDevirtualizerTest.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexDevirtualizerTest.java
index 7576780..29f2f79 100644
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexDevirtualizerTest.java
+++ b/src/test/java/com/android/tools/r8/maindexlist/MainDexDevirtualizerTest.java
@@ -80,19 +80,6 @@
         });
   }
 
-  // TODO(b/181858113): This test is likely obsolete once main-dex-list support is removed.
-  @Test
-  public void testMainDexClasses() throws Exception {
-    assumeTrue(parameters.isDexRuntime());
-    assumeTrue(parameters.getDexRuntimeVersion().isDalvik());
-    runTest(
-        r8FullTestBuilder ->
-            r8FullTestBuilder
-                .addMainDexListClasses(I.class, Provider.class, Main.class)
-                .allowDiagnosticWarningMessages(),
-        this::inspect);
-  }
-
   @Test
   public void testMainDexTracing() throws Exception {
     assumeTrue(parameters.isDexRuntime());
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainDexInliningSpuriousRootTest.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainDexInliningSpuriousRootTest.java
deleted file mode 100644
index 0b04ddc..0000000
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainDexInliningSpuriousRootTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-// Copyright (c) 2021, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.maindexlist;
-
-import static com.android.tools.r8.DiagnosticsMatcher.diagnosticType;
-import static com.android.tools.r8.utils.codeinspector.CodeMatchers.invokesMethod;
-import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-
-import com.android.tools.r8.NeverInline;
-import com.android.tools.r8.NoHorizontalClassMerging;
-import com.android.tools.r8.R8TestCompileResult;
-import com.android.tools.r8.TestBase;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.TestParametersCollection;
-import com.android.tools.r8.ToolHelper;
-import com.android.tools.r8.errors.UnsupportedMainDexListUsageDiagnostic;
-import com.android.tools.r8.references.ClassReference;
-import com.android.tools.r8.utils.codeinspector.ClassSubject;
-import com.android.tools.r8.utils.codeinspector.CodeInspector;
-import com.android.tools.r8.utils.codeinspector.MethodSubject;
-import com.google.common.collect.ImmutableSet;
-import java.util.List;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class MainDexListFromGenerateMainDexInliningSpuriousRootTest extends TestBase {
-
-  private static List<ClassReference> mainDexList;
-  private final TestParameters parameters;
-
-  @Parameters(name = "{0}")
-  public static TestParametersCollection data() {
-    return getTestParameters()
-        .withDexRuntimes()
-        .withApiLevelsEndingAtExcluding(apiLevelWithNativeMultiDexSupport())
-        .build();
-  }
-
-  @BeforeClass
-  public static void setup() throws Exception {
-    mainDexList =
-        testForMainDexListGenerator(getStaticTemp())
-            .addInnerClasses(MainDexListFromGenerateMainDexInliningSpuriousRootTest.class)
-            .addLibraryFiles(ToolHelper.getMostRecentAndroidJar())
-            .addMainDexRules(
-                "-keep class " + Main.class.getTypeName() + " {",
-                "  public static void main(java.lang.String[]);",
-                "}")
-            .run()
-            .getMainDexList();
-  }
-
-  public MainDexListFromGenerateMainDexInliningSpuriousRootTest(TestParameters parameters) {
-    this.parameters = parameters;
-  }
-
-  // TODO(b/181858113): This test is likely obsolete once main-dex-list support is removed.
-  @Test
-  public void test() throws Exception {
-    // The generated main dex list should contain Main (which is a root) and A (which is a direct
-    // dependency of Main).
-    assertEquals(2, mainDexList.size());
-    assertEquals(A.class.getTypeName(), mainDexList.get(0).getTypeName());
-    assertEquals(Main.class.getTypeName(), mainDexList.get(1).getTypeName());
-    R8TestCompileResult compileResult =
-        testForR8(parameters.getBackend())
-            .addInnerClasses(getClass())
-            .addInliningAnnotations()
-            .addKeepClassAndMembersRules(Main.class)
-            .addKeepMainRule(Main2.class)
-            .addMainDexListClassReferences(mainDexList)
-            .addMainDexRules(
-                "-keep class " + Main2.class.getTypeName() + " {",
-                "  public static void main(java.lang.String[]);",
-                "}")
-            .collectMainDexClasses()
-            .enableInliningAnnotations()
-            .enableNoHorizontalClassMergingAnnotations()
-            .setMinApi(parameters)
-            .addDontObfuscate()
-            .allowDiagnosticMessages()
-            .compileWithExpectedDiagnostics(
-                diagnostics ->
-                    diagnostics
-                        .assertOnlyWarnings()
-                        .assertWarningsMatch(
-                            diagnosticType(UnsupportedMainDexListUsageDiagnostic.class)));
-    CodeInspector inspector = compileResult.inspector();
-    ClassSubject mainClassSubject = inspector.clazz(Main.class);
-    assertThat(mainClassSubject, isPresent());
-    MethodSubject fooMethodSubject = mainClassSubject.uniqueMethodWithOriginalName("foo");
-    assertThat(fooMethodSubject, isPresent());
-    ClassSubject main2ClassSubject = inspector.clazz(Main2.class);
-    assertThat(main2ClassSubject, isPresent());
-    ClassSubject aClassSubject = inspector.clazz(A.class);
-    assertThat(aClassSubject, isPresent());
-    MethodSubject barMethodSubject = aClassSubject.uniqueMethodWithOriginalName("bar");
-    assertThat(barMethodSubject, isPresent());
-    ClassSubject bClassSubject = inspector.clazz(B.class);
-    assertThat(bClassSubject, isPresent());
-    MethodSubject bazMethodSubject = bClassSubject.uniqueMethodWithOriginalName("baz");
-    assertThat(bazMethodSubject, isPresent());
-    assertThat(fooMethodSubject, invokesMethod(barMethodSubject));
-    assertThat(barMethodSubject, invokesMethod(bazMethodSubject));
-    assertEquals(
-        ImmutableSet.of(
-            mainClassSubject.getFinalName(),
-            main2ClassSubject.getFinalName(),
-            aClassSubject.getFinalName()),
-        compileResult.getMainDexClasses());
-  }
-
-  static class Main {
-
-    public static void main(String[] args) {
-      System.out.println("Main.main()");
-    }
-
-    static void foo() {
-      A.bar();
-    }
-  }
-
-  static class Main2 {
-
-    public static void main(String[] args) {
-      if (getFalse()) {
-        A.bar();
-      }
-    }
-
-    static boolean getFalse() {
-      return false;
-    }
-  }
-
-  @NoHorizontalClassMerging
-  static class A {
-    // Must not be inlined into Main.foo(), since that would cause B to become direct dependence of
-    // Main without ending up in the main dex.
-    static void bar() {
-      B.baz();
-    }
-  }
-
-  @NoHorizontalClassMerging
-  static class B {
-
-    @NeverInline
-    static void baz() {
-      System.out.println("B.baz");
-    }
-  }
-}
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainDexInliningTest.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainDexInliningTest.java
deleted file mode 100644
index 5c61a78..0000000
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainDexInliningTest.java
+++ /dev/null
@@ -1,151 +0,0 @@
-// Copyright (c) 2021, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package com.android.tools.r8.maindexlist;
-
-import static com.android.tools.r8.DiagnosticsMatcher.diagnosticType;
-import static com.android.tools.r8.utils.codeinspector.CodeMatchers.invokesMethod;
-import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-
-import com.android.tools.r8.NeverInline;
-import com.android.tools.r8.NoHorizontalClassMerging;
-import com.android.tools.r8.R8TestCompileResult;
-import com.android.tools.r8.TestBase;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.TestParametersCollection;
-import com.android.tools.r8.ToolHelper;
-import com.android.tools.r8.errors.UnsupportedMainDexListUsageDiagnostic;
-import com.android.tools.r8.references.ClassReference;
-import com.android.tools.r8.utils.codeinspector.ClassSubject;
-import com.android.tools.r8.utils.codeinspector.CodeInspector;
-import com.android.tools.r8.utils.codeinspector.MethodSubject;
-import com.google.common.collect.ImmutableSet;
-import java.util.List;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class MainDexListFromGenerateMainDexInliningTest extends TestBase {
-
-  private static List<ClassReference> mainDexList;
-
-  private final TestParameters parameters;
-
-  @Parameters(name = "{0}")
-  public static TestParametersCollection data() {
-    return getTestParameters()
-        .withDexRuntimes()
-        .withApiLevelsEndingAtExcluding(apiLevelWithNativeMultiDexSupport())
-        .build();
-  }
-
-  @BeforeClass
-  public static void setup() throws Exception {
-    mainDexList =
-        testForMainDexListGenerator(getStaticTemp())
-            .addInnerClasses(MainDexListFromGenerateMainDexInliningTest.class)
-            .addLibraryFiles(ToolHelper.getMostRecentAndroidJar())
-            .addMainDexRules(
-                "-keep class " + Main.class.getTypeName() + " {",
-                "  public static void main(java.lang.String[]);",
-                "}")
-            .run()
-            .getMainDexList();
-  }
-
-  public MainDexListFromGenerateMainDexInliningTest(TestParameters parameters) {
-    this.parameters = parameters;
-  }
-
-  // TODO(b/181858113): This test is likely obsolete once main-dex-list support is removed.
-  @Test
-  public void test() throws Exception {
-    // The generated main dex list should contain Main (which is a root) and A (which is a direct
-    // dependency of Main).
-    assertEquals(2, mainDexList.size());
-    assertEquals(A.class.getTypeName(), mainDexList.get(0).getTypeName());
-    assertEquals(Main.class.getTypeName(), mainDexList.get(1).getTypeName());
-
-    R8TestCompileResult compileResult =
-        testForR8(parameters.getBackend())
-            .addInnerClasses(getClass())
-            .addInliningAnnotations()
-            .addKeepClassAndMembersRules(Main.class)
-            .addMainDexListClassReferences(mainDexList)
-            .collectMainDexClasses()
-            .enableInliningAnnotations()
-            .enableNoHorizontalClassMergingAnnotations()
-            .enableNoHorizontalClassMergingAnnotations()
-            .setMinApi(parameters)
-            .allowDiagnosticMessages()
-            .compileWithExpectedDiagnostics(
-                diagnostics ->
-                    diagnostics
-                        .assertOnlyWarnings()
-                        .assertWarningsMatch(
-                            diagnosticType(UnsupportedMainDexListUsageDiagnostic.class)));
-
-    CodeInspector inspector = compileResult.inspector();
-    ClassSubject mainClassSubject = inspector.clazz(Main.class);
-    assertThat(mainClassSubject, isPresent());
-
-    MethodSubject fooMethodSubject = mainClassSubject.uniqueMethodWithOriginalName("foo");
-    assertThat(fooMethodSubject, isPresent());
-
-    ClassSubject aClassSubject = inspector.clazz(A.class);
-    assertThat(aClassSubject, isPresent());
-
-    MethodSubject barMethodSubject = aClassSubject.uniqueMethodWithOriginalName("bar");
-    assertThat(barMethodSubject, isPresent());
-
-    ClassSubject bClassSubject = inspector.clazz(B.class);
-    assertThat(bClassSubject, isPresent());
-
-    MethodSubject bazMethodSubject = bClassSubject.uniqueMethodWithOriginalName("baz");
-    assertThat(bazMethodSubject, isPresent());
-
-    assertThat(fooMethodSubject, invokesMethod(barMethodSubject));
-    assertThat(barMethodSubject, invokesMethod(bazMethodSubject));
-
-    // The main dex classes should be the same as the input main dex list.
-    assertEquals(
-        ImmutableSet.of(mainClassSubject.getFinalName(), aClassSubject.getFinalName()),
-        compileResult.getMainDexClasses());
-  }
-
-  static class Main {
-
-    public static void main(String[] args) {
-      System.out.println("Main.main()");
-    }
-
-    static void foo() {
-      // Should not allow inlining bar into foo(), since that adds B as a direct
-      // dependence, and we don't include the direct dependencies of main dex list classes.
-      A.bar();
-    }
-  }
-
-  @NoHorizontalClassMerging
-  static class A {
-
-    static void bar() {
-      B.baz();
-    }
-  }
-
-  @NoHorizontalClassMerging
-  static class B {
-
-    @NeverInline
-    static void baz() {
-      System.out.println("B.baz");
-    }
-  }
-}
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainDexInliningWithTracingTest.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainDexInliningWithTracingTest.java
deleted file mode 100644
index 5a4d15c..0000000
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainDexInliningWithTracingTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-// Copyright (c) 2021, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package com.android.tools.r8.maindexlist;
-
-import static com.android.tools.r8.DiagnosticsMatcher.diagnosticType;
-import static com.android.tools.r8.utils.codeinspector.CodeMatchers.invokesMethod;
-import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-
-import com.android.tools.r8.NeverInline;
-import com.android.tools.r8.NoHorizontalClassMerging;
-import com.android.tools.r8.R8TestCompileResult;
-import com.android.tools.r8.TestBase;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.TestParametersCollection;
-import com.android.tools.r8.ToolHelper;
-import com.android.tools.r8.errors.UnsupportedMainDexListUsageDiagnostic;
-import com.android.tools.r8.references.ClassReference;
-import com.android.tools.r8.utils.codeinspector.ClassSubject;
-import com.android.tools.r8.utils.codeinspector.CodeInspector;
-import com.android.tools.r8.utils.codeinspector.MethodSubject;
-import com.google.common.collect.ImmutableSet;
-import java.util.List;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-public class MainDexListFromGenerateMainDexInliningWithTracingTest extends TestBase {
-
-  private static List<ClassReference> mainDexList;
-
-  private final TestParameters parameters;
-
-  @Parameters(name = "{0}")
-  public static TestParametersCollection data() {
-    return getTestParameters()
-        .withDexRuntimes()
-        .withApiLevelsEndingAtExcluding(apiLevelWithNativeMultiDexSupport())
-        .build();
-  }
-
-  @BeforeClass
-  public static void setup() throws Exception {
-    mainDexList =
-        testForMainDexListGenerator(getStaticTemp())
-            .addInnerClasses(MainDexListFromGenerateMainDexInliningWithTracingTest.class)
-            .addLibraryFiles(ToolHelper.getMostRecentAndroidJar())
-            .addMainDexRules(
-                "-keep class " + Main.class.getTypeName() + " {",
-                "  public static void main(java.lang.String[]);",
-                "}")
-            .run()
-            .getMainDexList();
-  }
-
-  public MainDexListFromGenerateMainDexInliningWithTracingTest(TestParameters parameters) {
-    this.parameters = parameters;
-  }
-
-  // TODO(b/181858113): This test is likely obsolete once main-dex-list support is removed.
-  @Test
-  public void test() throws Exception {
-    // The generated main dex list should contain Main (which is a root) and A (which is a direct
-    // dependency of Main).
-    assertEquals(2, mainDexList.size());
-    assertEquals(A.class.getTypeName(), mainDexList.get(0).getTypeName());
-    assertEquals(Main.class.getTypeName(), mainDexList.get(1).getTypeName());
-
-    R8TestCompileResult compileResult =
-        testForR8(parameters.getBackend())
-            .addInnerClasses(getClass())
-            .addInliningAnnotations()
-            .addKeepClassAndMembersRules(Main.class)
-            .addMainDexListClassReferences(mainDexList)
-            .addMainDexRules(
-                "-keep class " + Main.class.getTypeName() + " {",
-                "  public static void foo(java.lang.String[]);",
-                "}")
-            .collectMainDexClasses()
-            .enableInliningAnnotations()
-            .enableNoHorizontalClassMergingAnnotations()
-            .addDontObfuscate()
-            .setMinApi(parameters)
-            .allowDiagnosticMessages()
-            .compileWithExpectedDiagnostics(
-                diagnostics ->
-                    diagnostics
-                        .assertOnlyWarnings()
-                        .assertWarningsMatch(
-                            diagnosticType(UnsupportedMainDexListUsageDiagnostic.class)));
-
-    CodeInspector inspector = compileResult.inspector();
-    ClassSubject mainClassSubject = inspector.clazz(Main.class);
-    assertThat(mainClassSubject, isPresent());
-
-    MethodSubject fooMethodSubject = mainClassSubject.uniqueMethodWithOriginalName("foo");
-    assertThat(fooMethodSubject, isPresent());
-
-    MethodSubject notCalledAtStartupMethodSubject =
-        mainClassSubject.uniqueMethodWithOriginalName("notCalledAtStartup");
-    assertThat(notCalledAtStartupMethodSubject, isPresent());
-
-    ClassSubject aClassSubject = inspector.clazz(A.class);
-    assertThat(aClassSubject, isPresent());
-
-    MethodSubject barMethodSubject = aClassSubject.uniqueMethodWithOriginalName("bar");
-    assertThat(barMethodSubject, isPresent());
-
-    ClassSubject bClassSubject = inspector.clazz(B.class);
-    assertThat(bClassSubject, isPresent());
-
-    MethodSubject bazMethodSubject = bClassSubject.uniqueMethodWithOriginalName("baz");
-    assertThat(bazMethodSubject, isPresent());
-
-    assertThat(notCalledAtStartupMethodSubject, invokesMethod(barMethodSubject));
-    assertThat(barMethodSubject, invokesMethod(bazMethodSubject));
-
-    // The main dex classes should be the same as the input main dex list.
-    assertEquals(
-        ImmutableSet.of(mainClassSubject.getFinalName(), aClassSubject.getFinalName()),
-        compileResult.getMainDexClasses());
-  }
-
-  static class Main {
-
-    public static void main(String[] args) {
-      System.out.println("Main.main()");
-    }
-
-    public static void notCalledAtStartup() {
-      // Should not allow inlining bar into notCalledAtStartup(), since that adds B as a direct
-      // dependence, and we don't include the direct dependencies of main dex list classes.
-      new A().bar();
-    }
-
-    // This method is traced for main dex when running with R8, to add A as a dependency.
-    static A foo(A a) {
-      if (a != null) {
-        System.out.println("Hello World");
-      }
-      return a;
-    }
-  }
-
-  @NoHorizontalClassMerging
-  static class A {
-
-    static void bar() {
-      B.baz();
-    }
-  }
-
-  @NoHorizontalClassMerging
-  static class B {
-
-    @NeverInline
-    static void baz() {
-      System.out.println("B.baz");
-    }
-  }
-}
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainHorizontalMergingTest.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainHorizontalMergingTest.java
index 97d9c79..0125e03 100644
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainHorizontalMergingTest.java
+++ b/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainHorizontalMergingTest.java
@@ -38,7 +38,6 @@
 @RunWith(Parameterized.class)
 public class MainDexListFromGenerateMainHorizontalMergingTest extends TestBase {
 
-  private static List<ClassReference> mainDexList;
   private final TestParameters parameters;
 
   @Parameters(name = "{0}")
@@ -49,36 +48,10 @@
         .build();
   }
 
-  @BeforeClass
-  public static void setup() throws Exception {
-    mainDexList =
-        testForMainDexListGenerator(getStaticTemp())
-            .addInnerClasses(MainDexListFromGenerateMainHorizontalMergingTest.class)
-            .addLibraryFiles(ToolHelper.getMostRecentAndroidJar())
-            .addMainDexRules(
-                "-keep class " + Main.class.getTypeName() + " { public static void foo(); }")
-            .run()
-            .getMainDexList();
-  }
-
   public MainDexListFromGenerateMainHorizontalMergingTest(TestParameters parameters) {
     this.parameters = parameters;
   }
 
-  // TODO(b/181858113): This test is likely obsolete once main-dex-list support is removed.
-  @Test
-  public void testMainDexList() throws Exception {
-    assertEquals(3, mainDexList.size());
-    Set<String> mainDexReferences =
-        mainDexList.stream().map(TypeReference::getTypeName).collect(Collectors.toSet());
-    assertTrue(mainDexReferences.contains(A.class.getTypeName()));
-    assertTrue(mainDexReferences.contains(B.class.getTypeName()));
-    assertTrue(mainDexReferences.contains(Main.class.getTypeName()));
-    runTest(
-        builder ->
-            builder.addMainDexListClassReferences(mainDexList).allowDiagnosticWarningMessages());
-  }
-
   @Test
   public void testMainDexTracing() throws Exception {
     runTest(
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainVerticalMergingTest.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainVerticalMergingTest.java
index 4dba7f0..6ad455d 100644
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainVerticalMergingTest.java
+++ b/src/test/java/com/android/tools/r8/maindexlist/MainDexListFromGenerateMainVerticalMergingTest.java
@@ -37,8 +37,6 @@
 @RunWith(Parameterized.class)
 public class MainDexListFromGenerateMainVerticalMergingTest extends TestBase {
 
-  private static List<ClassReference> mainDexList;
-
   private final TestParameters parameters;
 
   @Parameters(name = "{0}")
@@ -49,36 +47,10 @@
         .build();
   }
 
-  @BeforeClass
-  public static void setup() throws Exception {
-    mainDexList =
-        testForMainDexListGenerator(getStaticTemp())
-            .addInnerClasses(MainDexListFromGenerateMainVerticalMergingTest.class)
-            .addLibraryFiles(ToolHelper.getMostRecentAndroidJar())
-            .addMainDexRules(
-                "-keep class " + Main.class.getTypeName() + " { public static void foo(); }")
-            .run()
-            .getMainDexList();
-  }
-
   public MainDexListFromGenerateMainVerticalMergingTest(TestParameters parameters) {
     this.parameters = parameters;
   }
 
-  // TODO(b/181858113): This test is likely obsolete once main-dex-list support is removed.
-  @Test
-  public void testMainDexList() throws Exception {
-    assertEquals(3, mainDexList.size());
-    Set<String> mainDexReferences =
-        mainDexList.stream().map(TypeReference::getTypeName).collect(Collectors.toSet());
-    assertTrue(mainDexReferences.contains(A.class.getTypeName()));
-    assertTrue(mainDexReferences.contains(B.class.getTypeName()));
-    assertTrue(mainDexReferences.contains(Main.class.getTypeName()));
-    runTest(
-        builder ->
-            builder.addMainDexListClassReferences(mainDexList).allowDiagnosticWarningMessages());
-  }
-
   @Test
   public void testMainTracing() throws Exception {
     runTest(
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexListInliningTest.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexListInliningTest.java
deleted file mode 100644
index 5e24bcf..0000000
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexListInliningTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) 2021, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package com.android.tools.r8.maindexlist;
-
-import static com.android.tools.r8.DiagnosticsMatcher.diagnosticType;
-import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import com.android.tools.r8.NoHorizontalClassMerging;
-import com.android.tools.r8.R8TestCompileResult;
-import com.android.tools.r8.TestBase;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.TestParametersCollection;
-import com.android.tools.r8.errors.UnsupportedMainDexListUsageDiagnostic;
-import com.android.tools.r8.utils.codeinspector.ClassSubject;
-import com.android.tools.r8.utils.codeinspector.CodeInspector;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-@RunWith(Parameterized.class)
-public class MainDexListInliningTest extends TestBase {
-
-  private final TestParameters parameters;
-
-  @Parameterized.Parameters(name = "{0}")
-  public static TestParametersCollection data() {
-    return getTestParameters()
-        .withDexRuntimes()
-        .withApiLevelsEndingAtExcluding(apiLevelWithNativeMultiDexSupport())
-        .build();
-  }
-
-  public MainDexListInliningTest(TestParameters parameters) {
-    this.parameters = parameters;
-  }
-
-  // TODO(b/181858113): This test should be converted to a main-dex-rules test.
-  @Test
-  public void test() throws Exception {
-    R8TestCompileResult compileResult =
-        testForR8(parameters.getBackend())
-            .addInnerClasses(getClass())
-            .addKeepMainRule(Main.class)
-            .addMainDexListClasses(Main.class)
-            .collectMainDexClasses()
-            .enableNoHorizontalClassMergingAnnotations()
-            .setMinApi(parameters)
-            .allowDiagnosticMessages()
-            .compileWithExpectedDiagnostics(
-                diagnostics ->
-                    diagnostics
-                        .assertOnlyWarnings()
-                        .assertWarningsMatch(
-                            diagnosticType(UnsupportedMainDexListUsageDiagnostic.class)));
-
-    CodeInspector inspector = compileResult.inspector();
-
-    ClassSubject mainClassSubject = inspector.clazz(Main.class);
-    assertThat(mainClassSubject, isPresent());
-
-    // A is not allowed to be inlined and is therefore present.
-    ClassSubject aClassSubject = inspector.clazz(A.class);
-    assertThat(aClassSubject, isPresent());
-
-    // B should be referenced from Main.main.
-    ClassSubject bClassSubject = inspector.clazz(B.class);
-    assertThat(bClassSubject, isPresent());
-
-    compileResult.inspectMainDexClasses(
-        mainDexClasses -> {
-          assertTrue(mainDexClasses.contains(mainClassSubject.getFinalName()));
-          // Since we passed a main-dex list the traced references A and B are not automagically
-          // included.
-          assertFalse(mainDexClasses.contains(aClassSubject.getFinalName()));
-          assertFalse(mainDexClasses.contains(bClassSubject.getFinalName()));
-        });
-  }
-
-  static class Main {
-
-    public static void main(String[] args) {
-      // Should be inlined.
-      A.m();
-    }
-  }
-
-  @NoHorizontalClassMerging
-  static class A {
-
-    public static void m() {
-      System.out.println(B.class);
-    }
-  }
-
-  @NoHorizontalClassMerging
-  static class B {}
-}
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexListNoDirectDependenciesTest.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexListNoDirectDependenciesTest.java
deleted file mode 100644
index a26fe55..0000000
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexListNoDirectDependenciesTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright (c) 2021, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package com.android.tools.r8.maindexlist;
-
-import static com.android.tools.r8.DiagnosticsMatcher.diagnosticType;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import com.android.tools.r8.R8TestCompileResult;
-import com.android.tools.r8.TestBase;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.TestParametersCollection;
-import com.android.tools.r8.errors.UnsupportedMainDexListUsageDiagnostic;
-import com.android.tools.r8.utils.codeinspector.ClassSubject;
-import com.android.tools.r8.utils.codeinspector.CodeInspector;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-@RunWith(Parameterized.class)
-public class MainDexListNoDirectDependenciesTest extends TestBase {
-
-  private final TestParameters parameters;
-
-  @Parameterized.Parameters(name = "{0}")
-  public static TestParametersCollection data() {
-    return getTestParameters()
-        .withDexRuntimes()
-        .withApiLevelsEndingAtExcluding(apiLevelWithNativeMultiDexSupport())
-        .build();
-  }
-
-  public MainDexListNoDirectDependenciesTest(TestParameters parameters) {
-    this.parameters = parameters;
-  }
-
-  // TODO(b/181858113): This test is likely obsolete once main-dex-list support is removed.
-  @Test
-  public void test() throws Exception {
-    R8TestCompileResult compileResult =
-        testForR8(parameters.getBackend())
-            .addInnerClasses(getClass())
-            .addMainDexListClasses(A.class)
-            .addMainDexKeepClassRules(B.class)
-            .collectMainDexClasses()
-            .noTreeShaking()
-            .setMinApi(parameters)
-            .allowDiagnosticMessages()
-            .compileWithExpectedDiagnostics(
-                diagnostics ->
-                    diagnostics
-                        .assertOnlyWarnings()
-                        .assertWarningsMatch(
-                            diagnosticType(UnsupportedMainDexListUsageDiagnostic.class)));
-
-    CodeInspector inspector = compileResult.inspector();
-
-    ClassSubject aClassSubject = inspector.clazz(A.class);
-    ClassSubject referencedFromAClassSubject = inspector.clazz(ReferencedFromA.class);
-    ClassSubject bClassSubject = inspector.clazz(B.class);
-    ClassSubject referencedFromBClassSubject = inspector.clazz(ReferencedFromB.class);
-
-    compileResult.inspectMainDexClasses(
-        mainDexClasses -> {
-          assertTrue(mainDexClasses.contains(aClassSubject.getFinalName()));
-          // It is assumed that the provided main dex list includes its direct dependencies.
-          // Therefore, we explicitly do not include the direct dependencies of the main dex list
-          // classes in the final main dex, since this would lead to the dependencies of the
-          // dependencies being included in the main dex.
-          assertFalse(mainDexClasses.contains(referencedFromAClassSubject.getFinalName()));
-          assertTrue(mainDexClasses.contains(bClassSubject.getFinalName()));
-          assertTrue(mainDexClasses.contains(referencedFromBClassSubject.getFinalName()));
-        });
-  }
-
-  static class A {
-
-    public void m() {
-      System.out.println(ReferencedFromA.class);
-    }
-  }
-
-  static class ReferencedFromA {}
-
-  static class B {
-
-    public void m() {
-      System.out.println(ReferencedFromB.class);
-    }
-  }
-
-  static class ReferencedFromB {}
-}
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexListTests.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexListTests.java
index 0da2423..98a3739 100644
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexListTests.java
+++ b/src/test/java/com/android/tools/r8/maindexlist/MainDexListTests.java
@@ -10,16 +10,14 @@
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import com.android.tools.r8.ByteDataView;
-import com.android.tools.r8.ClassFileConsumer.ArchiveConsumer;
 import com.android.tools.r8.CompilationFailedException;
 import com.android.tools.r8.CompilationMode;
 import com.android.tools.r8.D8;
 import com.android.tools.r8.D8Command;
+import com.android.tools.r8.D8TestBuilder;
 import com.android.tools.r8.DiagnosticsHandler;
 import com.android.tools.r8.DiagnosticsMatcher;
 import com.android.tools.r8.OutputMode;
-import com.android.tools.r8.R8Command;
 import com.android.tools.r8.StringResource;
 import com.android.tools.r8.TestBase;
 import com.android.tools.r8.TestDiagnosticMessagesImpl;
@@ -566,16 +564,14 @@
           originalInspector.clazz(clazz).isPresent());
     }
     Path outDir = temp.newFolder().toPath();
-    R8Command.Builder builder =
-        R8Command.builder(handler)
+    D8Command.Builder builder =
+        D8Command.builder(handler)
             .addProgramFiles(app)
             .setMode(
                 minimalMainDex && mainDex.size() > 0
                     ? CompilationMode.DEBUG
                     : CompilationMode.RELEASE)
-            .setOutput(outDir, OutputMode.DexIndexed)
-            .setDisableTreeShaking(true)
-            .setDisableMinification(true);
+            .setOutput(outDir, OutputMode.DexIndexed);
 
     switch (testMode) {
       case SINGLE_FILE:
@@ -619,7 +615,7 @@
       }
     }
 
-    ToolHelper.runR8(builder.build());
+    D8.run(builder.build());
     if (!singleDexApp && !minimalMainDex) {
       assertTrue("Output run only produced one dex file.",
           1 < Files.list(outDir).filter(FileUtils::isDexFile).count());
@@ -671,7 +667,9 @@
 
   private static void generateApplication(Path output, List<String> classes, int methodCount)
       throws IOException {
-    ArchiveConsumer consumer = new ArchiveConsumer(output);
+    // Translate and compile the app to DEX code as main-dex list requires DEX inputs.
+    D8TestBuilder builder =
+        testForD8(getStaticTemp(), Backend.DEX).setOutputMode(OutputMode.DexFilePerClass);
     for (String typename : classes) {
       String descriptor = DescriptorUtils.javaTypeToDescriptor(typename);
       byte[] bytes =
@@ -702,9 +700,13 @@
                     }
                   })
               .transform();
-      consumer.accept(ByteDataView.of(bytes), descriptor, null);
+      builder.addProgramClassFileData(bytes);
     }
-    consumer.finished(null);
+    try {
+      builder.compile().writeToZip(output);
+    } catch (CompilationFailedException e) {
+      throw new RuntimeException(e);
+    }
   }
 
   // Simple stub/template for generating the input classes.
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexPrunedReferenceTest.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexPrunedReferenceTest.java
index a5a07c4..8ce0413 100644
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexPrunedReferenceTest.java
+++ b/src/test/java/com/android/tools/r8/maindexlist/MainDexPrunedReferenceTest.java
@@ -48,15 +48,6 @@
     testMainDex(builder -> {}, Assert::assertNull);
   }
 
-  // TODO(b/181858113): This test is likely obsolete once main-dex-list support is removed.
-  @Test
-  public void testMainDexClassesList() throws Exception {
-    assumeTrue(parameters.getDexRuntimeVersion().isDalvik());
-    testMainDex(
-        builder -> builder.addMainDexListClasses(Main.class).allowDiagnosticWarningMessages(),
-        mainDexClasses -> assertEquals(ImmutableSet.of(Main.class.getTypeName()), mainDexClasses));
-  }
-
   @Test
   public void testMainDexTracing() throws Exception {
     assumeTrue(parameters.getDexRuntimeVersion().isDalvik());
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexRulesAndListD8.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexRulesAndListD8.java
deleted file mode 100644
index ae91c3d..0000000
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexRulesAndListD8.java
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (c) 2018, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-package com.android.tools.r8.maindexlist;
-
-import static org.junit.Assert.assertEquals;
-
-import com.android.tools.r8.TestBase;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.TestParametersCollection;
-import com.android.tools.r8.utils.FileUtils;
-import com.android.tools.r8.utils.ZipUtils;
-import com.google.common.collect.ImmutableList;
-import java.nio.file.Path;
-import java.util.List;
-import java.util.stream.Collectors;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-@RunWith(Parameterized.class)
-public class MainDexRulesAndListD8 extends TestBase {
-
-  private final TestParameters parameters;
-
-  @Parameterized.Parameters(name = "{0}")
-  public static TestParametersCollection data() {
-    return getTestParameters().withDexRuntimes().withApiLevelsWithoutNativeMultiDex().build();
-  }
-
-  public MainDexRulesAndListD8(TestParameters parameters) {
-    this.parameters = parameters;
-  }
-
-  private static Path testDir;
-  private static Path mainDexRules;
-  private static Path mainDexList;
-
-  @BeforeClass
-  public static void setUp() throws Exception {
-    testDir = getStaticTemp().newFolder().toPath();
-    mainDexRules = testDir.resolve("main-dex-rules");
-    mainDexList = testDir.resolve("main-dex-list");
-    FileUtils.writeTextFile(mainDexRules, ImmutableList.of("-keep class " + A.class.getTypeName()));
-    FileUtils.writeTextFile(
-        mainDexList, ImmutableList.of(B.class.getTypeName().replace('.', '/') + ".class"));
-  }
-
-  @Test
-  public void test() throws Exception {
-    Path result =
-        testForD8(parameters.getBackend())
-            .setMinApi(parameters)
-            .addInnerClasses(getClass())
-            .addMainDexRulesFiles(mainDexRules)
-            .addMainDexListFiles(mainDexList)
-            .debug()
-            .compile()
-            .writeToZip();
-    List<Path> dexFiles =
-        ZipUtils.unzip(result, testDir).stream().sorted().collect(Collectors.toList());
-    assertEquals(
-        classNamesFromDexFile(dexFiles.get(0)).stream().sorted().collect(Collectors.toList()),
-        ImmutableList.of(A.class.getTypeName(), B.class.getTypeName()));
-    assertEquals(
-        classNamesFromDexFile(dexFiles.get(1)).stream().sorted().collect(Collectors.toList()),
-        ImmutableList.of(C.class.getTypeName()));
-  }
-
-  static class A {}
-
-  static class B {}
-
-  static class C {}
-}
diff --git a/src/test/java/com/android/tools/r8/maindexlist/MainDexWithSynthesizedClassesTest.java b/src/test/java/com/android/tools/r8/maindexlist/MainDexWithSynthesizedClassesTest.java
index 1f980f3..2cc6ad2 100644
--- a/src/test/java/com/android/tools/r8/maindexlist/MainDexWithSynthesizedClassesTest.java
+++ b/src/test/java/com/android/tools/r8/maindexlist/MainDexWithSynthesizedClassesTest.java
@@ -6,12 +6,13 @@
 import static com.android.tools.r8.DiagnosticsMatcher.diagnosticOrigin;
 import static com.android.tools.r8.DiagnosticsMatcher.diagnosticType;
 import static org.hamcrest.CoreMatchers.allOf;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assume.assumeTrue;
 
+import com.android.tools.r8.CompilationFailedException;
 import com.android.tools.r8.D8TestCompileResult;
 import com.android.tools.r8.OutputMode;
-import com.android.tools.r8.R8TestCompileResult;
 import com.android.tools.r8.TestBase;
 import com.android.tools.r8.TestCompileResult;
 import com.android.tools.r8.TestDiagnosticMessages;
@@ -125,72 +126,35 @@
    * determined that TestClass and A are both traced. Thus the synthetic lambda from A will be
    * included in the main-dex file.
    *
-   * <p>TODO(b/181858113): Update to assert an error is raised once deprecated period is over.
+   * <p>Now that b/181858113 is resolved to disallow this API usage, this test just checks the error
+   * is reported.
    */
   @Test
   public void testDeprecatedSyntheticsFromMainDexListD8() throws Exception {
     assumeTrue(parameters.isDexRuntime());
     Path mainDexFile = temp.newFile("maindex.list").toPath();
     FileUtils.writeTextFile(mainDexFile, binaryName(A.class) + ".class");
-    D8TestCompileResult compileResult =
-        testForD8()
-            .addInnerClasses(MainDexWithSynthesizedClassesTest.class)
-            .addMainDexListClasses(TestClass.class)
-            .addMainDexListFiles(mainDexFile)
-            .setMinApi(parameters)
-            .compileWithExpectedDiagnostics(
-                diagnostics ->
-                    diagnostics
-                        .assertOnlyWarnings()
-                        .assertWarningsMatch(
-                            // The "classes" addition has no origin.
-                            allOf(
-                                diagnosticType(UnsupportedMainDexListUsageDiagnostic.class),
-                                diagnosticOrigin(Origin.unknown())),
-                            // The "file" addition must have the file origin.
-                            allOf(
-                                diagnosticType(UnsupportedMainDexListUsageDiagnostic.class),
-                                diagnosticOrigin(new PathOrigin(mainDexFile)))));
-    checkCompilationResult(compileResult);
-  }
-
-  /**
-   * This test checks for maintained support of including synthetics from main-dex-list entries in
-   * the main-dex file. This test simulates that the tracing done at the class-file level has
-   * determined that TestClass and A are both traced. Thus the synthetic lambda from A will be
-   * included in the main-dex file.
-   *
-   * <p>TODO(b/181858113): Remove once deprecated main-dex-list is removed.
-   */
-  @Test
-  public void testDeprecatedSyntheticsFromMainDexListR8() throws Exception {
-    assumeTrue(parameters.isDexRuntime());
-    Path mainDexFile = temp.newFile("maindex.list").toPath();
-    FileUtils.writeTextFile(mainDexFile, binaryName(A.class) + ".class");
-    R8TestCompileResult compileResult =
-        testForR8(parameters.getBackend())
-            .addInnerClasses(MainDexWithSynthesizedClassesTest.class)
-            .setMinApi(parameters)
-            .addOptionsModification(o -> o.minimalMainDex = true)
-            .addMainDexListClasses(TestClass.class)
-            .addMainDexListFiles(mainDexFile)
-            .addDontObfuscate()
-            .noTreeShaking()
-            .allowDiagnosticWarningMessages()
-            .compileWithExpectedDiagnostics(
-                diagnostics ->
-                    diagnostics
-                        .assertOnlyWarnings()
-                        .assertWarningsMatch(
-                            // The "classes" addition has no origin.
-                            allOf(
-                                diagnosticType(UnsupportedMainDexListUsageDiagnostic.class),
-                                diagnosticOrigin(Origin.unknown())),
-                            // The "file" addition must have the file origin.
-                            allOf(
-                                diagnosticType(UnsupportedMainDexListUsageDiagnostic.class),
-                                diagnosticOrigin(new PathOrigin(mainDexFile)))));
-    checkCompilationResult(compileResult, compileResult.app);
+    assertThrows(
+        CompilationFailedException.class,
+        () ->
+            testForD8()
+                .addInnerClasses(MainDexWithSynthesizedClassesTest.class)
+                .addMainDexListClasses(TestClass.class)
+                .addMainDexListFiles(mainDexFile)
+                .setMinApi(parameters)
+                .compileWithExpectedDiagnostics(
+                    diagnostics ->
+                        diagnostics
+                            .assertOnlyErrors()
+                            .assertErrorsMatch(
+                                // The "classes" addition has no origin.
+                                allOf(
+                                    diagnosticType(UnsupportedMainDexListUsageDiagnostic.class),
+                                    diagnosticOrigin(Origin.unknown())),
+                                // The "file" addition must have the file origin.
+                                allOf(
+                                    diagnosticType(UnsupportedMainDexListUsageDiagnostic.class),
+                                    diagnosticOrigin(new PathOrigin(mainDexFile))))));
   }
 
   private void checkCompilationResult(D8TestCompileResult compileResult) throws Exception {
diff --git a/src/test/java/com/android/tools/r8/maindexlist/warnings/MainDexWarningsTest.java b/src/test/java/com/android/tools/r8/maindexlist/warnings/MainDexWarningsTest.java
index cb7e981..ecd91e7 100644
--- a/src/test/java/com/android/tools/r8/maindexlist/warnings/MainDexWarningsTest.java
+++ b/src/test/java/com/android/tools/r8/maindexlist/warnings/MainDexWarningsTest.java
@@ -4,13 +4,19 @@
 
 package com.android.tools.r8.maindexlist.warnings;
 
+import static com.android.tools.r8.DiagnosticsMatcher.diagnosticMessage;
+import static com.android.tools.r8.DiagnosticsMatcher.diagnosticType;
 import static com.android.tools.r8.utils.codeinspector.Matchers.isAbsent;
+import static org.hamcrest.CoreMatchers.allOf;
 import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.not;
 import static org.hamcrest.MatcherAssert.assertThat;
 
+import com.android.tools.r8.CompilationFailedException;
 import com.android.tools.r8.TestBase;
 import com.android.tools.r8.TestParameters;
 import com.android.tools.r8.TestParametersCollection;
+import com.android.tools.r8.errors.UnsupportedMainDexListUsageDiagnostic;
 import com.android.tools.r8.utils.AndroidApiLevel;
 import com.android.tools.r8.utils.codeinspector.CodeInspector;
 import com.google.common.collect.ImmutableList;
@@ -61,7 +67,7 @@
         .assertNoMessages();
   }
 
-  @Test
+  @Test(expected = CompilationFailedException.class)
   public void testWarningFromManualMainDexList() throws Exception {
     testForR8(parameters.getBackend())
         .setMinApi(AndroidApiLevel.K)
@@ -72,15 +78,21 @@
         .addMainDexListClasses(Static.class)
         .allowDiagnosticWarningMessages()
         .setMinApi(parameters)
-        .compile()
-        .inspect(this::classStaticGone)
-        .assertOnlyWarnings()
-        .assertWarningMessageThatMatches(containsString("Application does not contain"))
-        .assertWarningMessageThatMatches(containsString(Static.class.getTypeName()))
-        .assertWarningMessageThatMatches(containsString("as referenced in main-dex-list"));
+        .compileWithExpectedDiagnostics(
+            diagnostics -> {
+              diagnostics
+                  .assertNoInfos()
+                  .assertErrorsMatch(diagnosticType(UnsupportedMainDexListUsageDiagnostic.class))
+                  .assertWarningsMatch(
+                      allOf(
+                          diagnosticMessage(containsString("Application does not contain")),
+                          diagnosticMessage(containsString(Static.class.getTypeName())),
+                          diagnosticMessage(containsString("as referenced in main-dex-list")),
+                          not(diagnosticMessage(containsString(Static2.class.getTypeName())))));
+            });
   }
 
-  @Test
+  @Test(expected = CompilationFailedException.class)
   public void testWarningFromManualMainDexListWithRuleAsWell() throws Exception {
     testForR8(parameters.getBackend())
         .setMinApi(AndroidApiLevel.K)
@@ -93,13 +105,18 @@
         .addDontWarn(Static.class)
         .allowDiagnosticWarningMessages()
         .setMinApi(parameters)
-        .compile()
-        .inspect(this::classStaticGone)
-        .assertOnlyWarnings()
-        .assertWarningMessageThatMatches(containsString("Application does not contain"))
-        .assertWarningMessageThatMatches(containsString(Static.class.getTypeName()))
-        .assertWarningMessageThatMatches(containsString("as referenced in main-dex-list"))
-        .assertNoWarningMessageThatMatches(containsString(Static2.class.getTypeName()));
+        .compileWithExpectedDiagnostics(
+            diagnostics -> {
+              diagnostics
+                  .assertNoInfos()
+                  .assertErrorsMatch(diagnosticType(UnsupportedMainDexListUsageDiagnostic.class))
+                  .assertWarningsMatch(
+                      allOf(
+                          diagnosticMessage(containsString("Application does not contain")),
+                          diagnosticMessage(containsString(Static.class.getTypeName())),
+                          diagnosticMessage(containsString("as referenced in main-dex-list")),
+                          not(diagnosticMessage(containsString(Static2.class.getTypeName())))));
+            });
   }
 }
 
diff --git a/src/test/java/com/android/tools/r8/repackage/RepackageWithMainDexListTest.java b/src/test/java/com/android/tools/r8/repackage/RepackageWithMainDexListTest.java
deleted file mode 100644
index 170708d..0000000
--- a/src/test/java/com/android/tools/r8/repackage/RepackageWithMainDexListTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (c) 2020, the R8 project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-package com.android.tools.r8.repackage;
-
-import static com.android.tools.r8.DiagnosticsMatcher.diagnosticType;
-import static com.android.tools.r8.shaking.ProguardConfigurationParser.FLATTEN_PACKAGE_HIERARCHY;
-import static com.android.tools.r8.shaking.ProguardConfigurationParser.REPACKAGE_CLASSES;
-import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-import com.android.tools.r8.OutputMode;
-import com.android.tools.r8.R8TestCompileResult;
-import com.android.tools.r8.TestParameters;
-import com.android.tools.r8.errors.UnsupportedMainDexListUsageDiagnostic;
-import com.android.tools.r8.utils.codeinspector.CodeInspector;
-import com.google.common.collect.ImmutableList;
-import java.nio.file.Path;
-import java.util.List;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-// TODO(b/181858113): This test is likely obsolete once main-dex-list support is removed.
-@RunWith(Parameterized.class)
-public class RepackageWithMainDexListTest extends RepackageTestBase {
-
-  @Parameters(name = "{1}, kind: {0}")
-  public static List<Object[]> data() {
-    return buildParameters(
-        ImmutableList.of(FLATTEN_PACKAGE_HIERARCHY, REPACKAGE_CLASSES),
-        getTestParameters()
-            .withDexRuntimes()
-            .withApiLevelsEndingAtExcluding(apiLevelWithNativeMultiDexSupport())
-            .build());
-  }
-
-  public RepackageWithMainDexListTest(
-      String flattenPackageHierarchyOrRepackageClasses, TestParameters parameters) {
-    super(flattenPackageHierarchyOrRepackageClasses, parameters);
-  }
-
-  @Test
-  public void test() throws Exception {
-    testForR8(parameters.getBackend())
-        .addInnerClasses(getClass())
-        // -keep,allowobfuscation does not prohibit repackaging.
-        .addKeepClassRulesWithAllowObfuscation(TestClass.class, OtherTestClass.class)
-        .addKeepRules(
-            "-keepclassmembers class " + TestClass.class.getTypeName() + " { <methods>; }")
-        // Add a class that will be repackaged to the main dex list.
-        .addMainDexListClasses(TestClass.class)
-        .apply(this::configureRepackaging)
-        // Debug mode to enable minimal main dex.
-        .debug()
-        .setMinApi(parameters)
-        .allowDiagnosticMessages()
-        .compileWithExpectedDiagnostics(
-            diagnostics ->
-                diagnostics
-                    .assertOnlyWarnings()
-                    .assertWarningsMatch(
-                        diagnosticType(UnsupportedMainDexListUsageDiagnostic.class)))
-        .apply(this::checkCompileResult)
-        .run(parameters.getRuntime(), TestClass.class)
-        .assertSuccessWithOutputLines("Hello world!");
-  }
-
-  private void checkCompileResult(R8TestCompileResult compileResult) throws Exception {
-    Path out = temp.newFolder().toPath();
-    compileResult.app.writeToDirectory(out, OutputMode.DexIndexed);
-    Path classes = out.resolve("classes.dex");
-    Path classes2 = out.resolve("classes2.dex");
-    inspectMainDex(new CodeInspector(classes, compileResult.getProguardMap()));
-    inspectSecondaryDex(new CodeInspector(classes2, compileResult.getProguardMap()));
-  }
-
-  private void inspectMainDex(CodeInspector inspector) {
-    assertThat(inspector.clazz(TestClass.class), isPresent());
-    assertThat(inspector.clazz(OtherTestClass.class), not(isPresent()));
-  }
-
-  private void inspectSecondaryDex(CodeInspector inspector) {
-    assertThat(inspector.clazz(TestClass.class), not(isPresent()));
-    assertThat(inspector.clazz(OtherTestClass.class), isPresent());
-  }
-
-  static class TestClass {
-
-    public static void main(String[] args) {
-      System.out.println("Hello world!");
-    }
-  }
-
-  static class OtherTestClass {}
-}
diff --git a/third_party/binary_compatibility_tests/compiler_api_tests.tar.gz.sha1 b/third_party/binary_compatibility_tests/compiler_api_tests.tar.gz.sha1
index be228fe..5f24411 100644
--- a/third_party/binary_compatibility_tests/compiler_api_tests.tar.gz.sha1
+++ b/third_party/binary_compatibility_tests/compiler_api_tests.tar.gz.sha1
@@ -1 +1 @@
-3132dcd12de5ed9368718c30dfe892a7c7af4b10
+37caffb18e8b47c65512ff667a3d6e91c23e6734
\ No newline at end of file