Flatten dependency hierarchy of legacy-android-test

Previous changes statically included legacy-android-test in preparation
for removing android.test.* and junit.* classes from the android.jar.
Unfortunately, that lead to duplicate classes between APKs and the
bootclasspath which caused build problems (Proguard) and also runtime
problems (when targeting and running on older releases).

Switching from statically including the classes to using the runtime
libraries cannot be done in one step because legacy-android-test is
statically included in libraries which are used in many APKs and so
removing it from those libraries requires that all APKs be updated at
once. Doing that atomically across dozens of projects is not practical.

This change modifies APKS that statically include the
legacy-android-test library indirectly.

* If the APK manifest uses the android.test.runner library then the APK
  is modified to stop statically including legacy-android-test and
  instead build against android.test.base/mock/runner libraries instead.

* Otherwise, the APK statically includes legacy-android-test.

Also, any libraries that statically include are modified to stop
statically including it and if it has source dependencies on the classes
is changed to build against the android.test.base/mock/runner libraries.

The following change descriptions were generated automatically and so
may be a little repetitive. They are provided to give the reviewer
enough information to check the comments match what has actually been
changed and check the reasoning behind the changes.

* apps/CtsVerifier/Android.mk
    Removed legacy-android-test from LOCAL_JAVA_LIBRARIES because it is
    unnecessary as CtsVerifier's source does not depend on classes from
    legacy-android-test. The classes do not need to be statically
    included because the classes will be provided by the runtime,
    either from the default bootclasspath or from the
    android.test.runner library that CtsVerifier specifies in its
    manifest.

* common/device-side/device-info/Android.mk
    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because compatibility-device-info is not a package so does not need
    to statically include the classes

    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    compatibility-device-info has a source dependency on its classes

* common/device-side/device-info/tests/Android.mk
    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because compatibility-device-info-tests is not a package so does
    not need to statically include the classes

    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    compatibility-device-info-tests has a source dependency on its
    classes

* common/device-side/util/Android.mk
    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because compatibility-device-util is not a package so does not need
    to statically include the classes

* hostsidetests/abioverride/app/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsAbiOverrideTestApp was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/appsecurity/test-apps/AccessSerialModern/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsAccessSerialModern was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/appsecurity/test-apps/DocumentClient/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsDocumentClient's source depends on its classes and because of
    these changes they are no longer present on the compilation path.
    The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    CtsDocumentClient specifies in its manifest.

* hostsidetests/appsecurity/test-apps/DocumentProvider/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsDocumentProvider was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/appsecurity/test-apps/PermissionPolicy25/Android.mk
    Removed legacy-android-test from LOCAL_JAVA_LIBRARIES because it is
    unnecessary as CtsPermissionPolicyTest25's source does not depend
    on classes from legacy-android-test. The classes do not need to be
    statically included because the classes will be provided by the
    runtime, either from the default bootclasspath or from the
    android.test.runner library that CtsPermissionPolicyTest25
    specifies in its manifest.

* hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk
    Replaced 'legacy-android-test' with 'android.test.base' in
    LOCAL_JAVA_LIBRARIES because CtsUsePermissionApp22's source depends
    on its classes. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that CtsUsePermissionApp22 specifies in its manifest.

* hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsUsePermissionApp23 was statically linked to it through its
    dependency on compatibility-device-util

    Removed legacy-android-test from LOCAL_JAVA_LIBRARIES because it is
    unnecessary as CtsUsePermissionApp23 already statically includes
    legacy-android-test

* hostsidetests/appsecurity/test-apps/UsePermissionApp25/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsUsePermissionApp25 was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/appsecurity/test-apps/UsePermissionApp26/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsUsePermissionApp26 was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsUsePermissionAppLatest was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/devicepolicy/app/Assistant/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsDevicePolicyAssistApp was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/devicepolicy/app/CustomizationApp/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsCustomizationApp was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api23/Android.mk
    Replaced 'legacy-android-test' with 'android.test.runner.stubs' in
    LOCAL_JAVA_LIBRARIES because CtsDeviceAndProfileOwnerApp23's source
    depends on its classes. The classes do not need to be statically
    included because the classes will be provided by the runtime,
    either from the default bootclasspath or from the
    android.test.runner library that CtsDeviceAndProfileOwnerApp23
    specifies in its manifest.

* hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api25/Android.mk
    Replaced 'legacy-android-test' with 'android.test.runner.stubs' in
    LOCAL_JAVA_LIBRARIES because CtsDeviceAndProfileOwnerApp25's source
    depends on its classes. The classes do not need to be statically
    included because the classes will be provided by the runtime,
    either from the default bootclasspath or from the
    android.test.runner library that CtsDeviceAndProfileOwnerApp25
    specifies in its manifest.

* hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsDeviceAndProfileOwnerApp's source depends on its classes and
    because of these changes they are no longer present on the
    compilation path. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that CtsDeviceAndProfileOwnerApp specifies in its manifest.

* hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsWifiConfigCreator was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/dumpsys/apps/ProcStatsHelperApp/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsProcStatsHelperApp was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/media/app/MediaSessionTest/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsMediaSessionHostTestApp was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/net/app/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsHostsideNetworkTestsApp's source depends on its classes and
    because of these changes they are no longer present on the
    compilation path. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that CtsHostsideNetworkTestsApp specifies in its manifest.

* hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsStaticSharedLibConsumerApp1 was statically linked to it through
    its dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/launcher1/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupLauncher1 was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/launcher2/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupLauncher2 was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/launcher3/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupLauncher3 was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/launcher4new/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupLauncher4new was statically linked to it through
    its dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/launcher4old/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupLauncher4old was statically linked to it through
    its dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/publisher1/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupPublisher1 was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/publisher2/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupPublisher2 was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/publisher3/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupPublisher3 was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/publisher4new/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupPublisher4new was statically linked to it through
    its dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/publisher4new_nobackup/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupPublisher4new_nobackup was statically linked to it
    through its dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/publisher4new_nomanifest/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupPublisher4new_nomanifest was statically linked to
    it through its dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/publisher4new_wrongkey/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupPublisher4new_wrongkey was statically linked to it
    through its dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/publisher4old/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupPublisher4old was statically linked to it through
    its dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/backup/publisher4old_nomanifest/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutBackupPublisher4old_nomanifest was statically linked to
    it through its dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/multiuser/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutMultiuserTest was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/shortcuts/deviceside/upgrade/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutUpgradeVersion1 was statically linked to it through its
    dependency on compatibility-device-util

    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutUpgradeVersion2 was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/ui/appA/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsDeviceTaskSwitchingAppA was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/ui/appB/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsDeviceTaskSwitchingAppB was statically linked to it through its
    dependency on compatibility-device-util

* hostsidetests/webkit/app/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsWebViewStartupApp's source depends on its classes and because of
    these changes they are no longer present on the compilation path.
    The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    CtsWebViewStartupApp specifies in its manifest.

* libs/deviceutillegacy/Android.mk
    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because ctsdeviceutillegacy is not a package so does not need to
    statically include the classes

    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    ctsdeviceutillegacy has a source dependency on its classes

* tests/JobScheduler/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    CtsJobSchedulerTestCases's source depends on its classes and
    because of these changes they are no longer present on the
    compilation path. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that CtsJobSchedulerTestCases specifies in its manifest.

* tests/JobScheduler/jobperm/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsJobSchedulerJobPerm was statically linked to it through its
    dependency on compatibility-device-util

* tests/JobScheduler/shareduid/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsJobSchedulerSharedUid was statically linked to it through its
    dependency on compatibility-device-util

* tests/admin/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsAdminTestCases's source depends on its classes and because of
    these changes they are no longer present on the compilation path.
    The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    CtsAdminTestCases specifies in its manifest.

* tests/app/app2/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsAppTestStubsDifferentUid was statically linked to it through its
    dependency on compatibility-device-util

* tests/backup/app/fullbackup/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsFullBackupApp was statically linked to it through its dependency
    on compatibility-device-util

* tests/backup/app/keyvalue/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsKeyValueBackupApp was statically linked to it through its
    dependency on compatibility-device-util

* tests/framework/base/windowmanager/alertwindowservice/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsAlertWindowService was statically linked to it through its
    dependency on compatibility-device-util

* tests/leanbackjank/app/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsLeanbackJankApp was statically linked to it through its
    dependency on compatibility-device-util

* tests/tests/alarmclock/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsAlarmClockTestCases's source depends on its classes and because
    of these changes they are no longer present on the compilation
    path. The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    CtsAlarmClockTestCases specifies in its manifest.

* tests/tests/assist/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsAssistTestCases's source depends on its classes and because of
    these changes they are no longer present on the compilation path.
    The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    CtsAssistTestCases specifies in its manifest.

* tests/tests/dpi/Android.mk
    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because android.cts.dpi is not a package so does not need to
    statically include the classes

    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    android.cts.dpi has a source dependency on its classes

* tests/tests/dpi2/Android.mk
    Removed legacy-android-test from LOCAL_JAVA_LIBRARIES because it is
    unnecessary as CtsDpiTestCases2's source does not depend on classes
    from legacy-android-test. The classes do not need to be statically
    included because the classes will be provided by the runtime,
    either from the default bootclasspath or from the
    android.test.runner library that CtsDpiTestCases2 specifies in its
    manifest.

* tests/tests/externalservice/service/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsExternalServiceService was statically linked to it through its
    dependency on compatibility-device-util

* tests/tests/mediastress/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsMediaStressTestCases's source depends on its classes and because
    of these changes they are no longer present on the compilation
    path. The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    CtsMediaStressTestCases specifies in its manifest.

* tests/tests/openglperf/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsOpenGlPerfTestCases's source depends on its classes and because
    of these changes they are no longer present on the compilation
    path. The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    CtsOpenGlPerfTestCases specifies in its manifest.

* tests/tests/provider/Android.mk
    Replaced 'legacy-android-test' with 'android.test.base' and
    'android.test.runner' in LOCAL_JAVA_LIBRARIES because
    CtsProviderTestCases's source depends on their classes. The classes
    do not need to be statically included because the classes will be
    provided by the runtime, either from the default bootclasspath or
    from the android.test.runner library that CtsProviderTestCases
    specifies in its manifest.

* tests/tests/selinux/selinuxTargetSdk/Android.mk
    Removed legacy-android-test from LOCAL_JAVA_LIBRARIES because it is
    unnecessary as CtsSelinuxTargetSdkTestCases's source does not
    depend on classes from legacy-android-test. The classes do not need
    to be statically included because the classes will be provided by
    the runtime, either from the default bootclasspath or from the
    android.test.runner library that CtsSelinuxTargetSdkTestCases
    specifies in its manifest.

* tests/tests/shortcutmanager/packages/launchermanifest/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutManagerLauncher1 was statically linked to it through its
    dependency on compatibility-device-util

    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutManagerLauncher2 was statically linked to it through its
    dependency on compatibility-device-util

    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutManagerLauncher3 was statically linked to it through its
    dependency on compatibility-device-util

* tests/tests/shortcutmanager/packages/launchermanifest_nonshared/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutManagerLauncher4 was statically linked to it through its
    dependency on compatibility-device-util

* tests/tests/shortcutmanager/packages/packagemanifest/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutManagerPackage1 was statically linked to it through its
    dependency on compatibility-device-util

    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutManagerPackage2 was statically linked to it through its
    dependency on compatibility-device-util

    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutManagerPackage3 was statically linked to it through its
    dependency on compatibility-device-util

* tests/tests/shortcutmanager/packages/packagemanifest_nonshared/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutManagerPackage4 was statically linked to it through its
    dependency on compatibility-device-util

* tests/tests/shortcutmanager/throttling/Android.mk
    Added 'legacy-android-test' to LOCAL_STATIC_JAVA_LIBRARIES because
    CtsShortcutManagerThrottlingTest was statically linked to it
    through its dependency on compatibility-device-util

* tests/tests/voiceinteraction/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsVoiceInteractionTestCases's source depends on its classes and
    because of these changes they are no longer present on the
    compilation path. The classes do not need to be statically included
    because the classes will be provided by the runtime, either from
    the default bootclasspath or from the android.test.runner library
    that CtsVoiceInteractionTestCases specifies in its manifest.

* tests/tests/webkit/Android.mk
    Added 'android.test.base' to LOCAL_JAVA_LIBRARIES because
    CtsWebkitTestCases's source depends on its classes and because of
    these changes they are no longer present on the compilation path.
    The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    CtsWebkitTestCases specifies in its manifest.

* tests/ui/Android.mk
    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    CtsUiDeviceTestCases's source depends on its classes and because of
    these changes they are no longer present on the compilation path.
    The classes do not need to be statically included because the
    classes will be provided by the runtime, either from the default
    bootclasspath or from the android.test.runner library that
    CtsUiDeviceTestCases specifies in its manifest.

* tools/cts-reference-app-lib/Android.mk
    Removed legacy-android-test from LOCAL_STATIC_JAVA_LIBRARIES
    because android.cts.refapp is not a package so does not need to
    statically include the classes

    Added 'android.test.runner.stubs' to LOCAL_JAVA_LIBRARIES because
    android.cts.refapp has a source dependency on its classes

Bug: 30188076
Test: make checkbuild
Change-Id: Ief6940eacf333043e2324462d37d1fd35db15165
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index 724848e..8b8dd8e 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -40,8 +40,6 @@
                                compatibility-device-util \
                                platform-test-annotations
 
-LOCAL_JAVA_LIBRARIES := legacy-android-test
-
 LOCAL_JAVA_LIBRARIES += telephony-common
 
 LOCAL_PACKAGE_NAME := CtsVerifier
diff --git a/common/device-side/device-info/Android.mk b/common/device-side/device-info/Android.mk
index bf6e122..4ab1ac6 100644
--- a/common/device-side/device-info/Android.mk
+++ b/common/device-side/device-info/Android.mk
@@ -23,8 +23,9 @@
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
     android-support-test \
-    junit \
-    legacy-android-test
+    junit
+
+LOCAL_JAVA_LIBRARIES := android.test.base
 
 LOCAL_MODULE := compatibility-device-info
 
diff --git a/common/device-side/device-info/tests/Android.mk b/common/device-side/device-info/tests/Android.mk
index d40614c..db4f250 100644
--- a/common/device-side/device-info/tests/Android.mk
+++ b/common/device-side/device-info/tests/Android.mk
@@ -18,9 +18,9 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-info junit legacy-android-test
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-info junit
 
-LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base
 
 LOCAL_MODULE_TAGS := optional
 
diff --git a/common/device-side/util/Android.mk b/common/device-side/util/Android.mk
index 26a37ec..36316b5 100644
--- a/common/device-side/util/Android.mk
+++ b/common/device-side/util/Android.mk
@@ -23,8 +23,7 @@
     compatibility-common-util-devicesidelib \
     android-support-test \
     ub-uiautomator \
-    mockito-target-minus-junit4 \
-    legacy-android-test
+    mockito-target-minus-junit4
 
 LOCAL_JAVA_LIBRARIES := android.test.runner
 
diff --git a/hostsidetests/abioverride/app/Android.mk b/hostsidetests/abioverride/app/Android.mk
index a246f72..13771a7 100755
--- a/hostsidetests/abioverride/app/Android.mk
+++ b/hostsidetests/abioverride/app/Android.mk
@@ -27,7 +27,11 @@
 
 LOCAL_MULTILIB := both
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    compatibility-device-util \
+    ctstestrunner \
+    legacy-android-test \
+
 
 LOCAL_JNI_SHARED_LIBRARIES := libctsabioverride
 
diff --git a/hostsidetests/appsecurity/test-apps/AccessSerialModern/Android.mk b/hostsidetests/appsecurity/test-apps/AccessSerialModern/Android.mk
index 20d51b6..6b45943 100644
--- a/hostsidetests/appsecurity/test-apps/AccessSerialModern/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/AccessSerialModern/Android.mk
@@ -22,6 +22,7 @@
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
     android-support-test \
+    legacy-android-test \
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/hostsidetests/appsecurity/test-apps/DocumentClient/Android.mk b/hostsidetests/appsecurity/test-apps/DocumentClient/Android.mk
index 0a55834..bac3086 100644
--- a/hostsidetests/appsecurity/test-apps/DocumentClient/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/DocumentClient/Android.mk
@@ -22,6 +22,8 @@
 LOCAL_SDK_VERSION := current
 LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-util ctstestrunner ub-uiautomator
 
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsDocumentClient
diff --git a/hostsidetests/appsecurity/test-apps/DocumentProvider/Android.mk b/hostsidetests/appsecurity/test-apps/DocumentProvider/Android.mk
index 7609e33..c1fd027 100644
--- a/hostsidetests/appsecurity/test-apps/DocumentProvider/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/DocumentProvider/Android.mk
@@ -20,7 +20,13 @@
 
 LOCAL_MODULE_TAGS := tests
 LOCAL_SDK_VERSION := current
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-util ctstestrunner ub-uiautomator
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-test \
+    compatibility-device-util \
+    ctstestrunner \
+    ub-uiautomator \
+    legacy-android-test \
+
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/hostsidetests/appsecurity/test-apps/PermissionPolicy25/Android.mk b/hostsidetests/appsecurity/test-apps/PermissionPolicy25/Android.mk
index 9206b6f..0d53ac8 100644
--- a/hostsidetests/appsecurity/test-apps/PermissionPolicy25/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/PermissionPolicy25/Android.mk
@@ -25,8 +25,6 @@
     compatibility-device-util \
     ctstestrunner \
 
-LOCAL_JAVA_LIBRARIES := legacy-android-test
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsPermissionPolicyTest25
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk
index 2b6c2b0..c98dbb1 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp22/Android.mk
@@ -25,7 +25,7 @@
     ctstestrunner \
     ub-uiautomator
 
-LOCAL_JAVA_LIBRARIES := legacy-android-test
+LOCAL_JAVA_LIBRARIES := android.test.base
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
     ../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java \
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk
index 305359c..60f22f8 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp23/Android.mk
@@ -23,9 +23,8 @@
     android-support-test \
     compatibility-device-util \
     ctstestrunner \
-    ub-uiautomator
-
-LOCAL_JAVA_LIBRARIES := legacy-android-test
+    ub-uiautomator \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
     ../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp25/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp25/Android.mk
index ac4f272..0744d4b 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp25/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp25/Android.mk
@@ -23,7 +23,8 @@
     android-support-test \
     compatibility-device-util \
     ctstestrunner \
-    ub-uiautomator
+    ub-uiautomator \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, ../UsePermissionApp23/src) \
     ../ExternalStorageApp/src/com/android/cts/externalstorageapp/CommonExternalStorageTest.java
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionApp26/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionApp26/Android.mk
index 7064288..05ebc47 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionApp26/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionApp26/Android.mk
@@ -23,7 +23,8 @@
     android-support-test \
     compatibility-device-util \
     ctstestrunner \
-    ub-uiautomator
+    ub-uiautomator \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src) \
     ../UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionActivity.java \
diff --git a/hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/Android.mk b/hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/Android.mk
index 62a15e4..574adcb 100644
--- a/hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/Android.mk
+++ b/hostsidetests/appsecurity/test-apps/UsePermissionAppLatest/Android.mk
@@ -23,7 +23,8 @@
     android-support-test \
     compatibility-device-util \
     ctstestrunner \
-    ub-uiautomator
+    ub-uiautomator \
+    legacy-android-test
 
 LOCAL_SRC_FILES := $(call all-java-files-under, ../UsePermissionApp26/src)  \
     ../UsePermissionApp23/src/com/android/cts/usepermission/BasePermissionActivity.java \
diff --git a/hostsidetests/devicepolicy/app/Assistant/Android.mk b/hostsidetests/devicepolicy/app/Assistant/Android.mk
index 86144a2..fa909d5 100644
--- a/hostsidetests/devicepolicy/app/Assistant/Android.mk
+++ b/hostsidetests/devicepolicy/app/Assistant/Android.mk
@@ -29,7 +29,12 @@
 
 LOCAL_PACKAGE_NAME := CtsDevicePolicyAssistApp
 
-LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 compatibility-device-util android-support-test
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-v4 \
+    compatibility-device-util \
+    android-support-test \
+    legacy-android-test \
+
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/devicepolicy/app/CustomizationApp/Android.mk b/hostsidetests/devicepolicy/app/CustomizationApp/Android.mk
index 1e6e2f1..09f6f53 100644
--- a/hostsidetests/devicepolicy/app/CustomizationApp/Android.mk
+++ b/hostsidetests/devicepolicy/app/CustomizationApp/Android.mk
@@ -26,8 +26,12 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-test \
+    compatibility-device-util \
+    legacy-android-test \
+
 
 LOCAL_SDK_VERSION := current
 
-include $(BUILD_CTS_PACKAGE)
\ No newline at end of file
+include $(BUILD_CTS_PACKAGE)
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api23/Android.mk b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api23/Android.mk
index c818856..3bdd5e0 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api23/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api23/Android.mk
@@ -24,7 +24,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
 
-LOCAL_JAVA_LIBRARIES = conscrypt legacy-android-test
+LOCAL_JAVA_LIBRARIES = conscrypt android.test.runner.stubs
 
 LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 compatibility-device-util ctstestrunner ub-uiautomator
 
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api25/Android.mk b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api25/Android.mk
index 1c50763..16e26b7 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api25/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/api25/Android.mk
@@ -24,7 +24,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
 
-LOCAL_JAVA_LIBRARIES = conscrypt legacy-android-test
+LOCAL_JAVA_LIBRARIES = conscrypt android.test.runner.stubs
 
 LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 compatibility-device-util ctstestrunner ub-uiautomator
 
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/Android.mk b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/Android.mk
index 81a23d2..a7ed338 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/Android.mk
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/latest/Android.mk
@@ -24,7 +24,7 @@
 
 LOCAL_SRC_FILES := $(call all-java-files-under, ../src)
 
-LOCAL_JAVA_LIBRARIES = conscrypt
+LOCAL_JAVA_LIBRARIES = conscrypt android.test.runner.stubs
 
 LOCAL_STATIC_JAVA_LIBRARIES = android-support-v4 compatibility-device-util ctstestrunner ub-uiautomator
 
diff --git a/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk b/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk
index b03cf95..874dd95 100644
--- a/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk
+++ b/hostsidetests/devicepolicy/app/WifiConfigCreator/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_PACKAGE_NAME := CtsWifiConfigCreator
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/dumpsys/apps/ProcStatsHelperApp/Android.mk b/hostsidetests/dumpsys/apps/ProcStatsHelperApp/Android.mk
index 3f7bd08..d4452e3 100644
--- a/hostsidetests/dumpsys/apps/ProcStatsHelperApp/Android.mk
+++ b/hostsidetests/dumpsys/apps/ProcStatsHelperApp/Android.mk
@@ -29,7 +29,8 @@
 LOCAL_STATIC_JAVA_LIBRARIES := \
     ctstestrunner \
     compatibility-device-util \
-    android-support-v4
+    android-support-v4 \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := test_current
 
diff --git a/hostsidetests/media/app/MediaSessionTest/Android.mk b/hostsidetests/media/app/MediaSessionTest/Android.mk
index fb0fe40..53f9824 100644
--- a/hostsidetests/media/app/MediaSessionTest/Android.mk
+++ b/hostsidetests/media/app/MediaSessionTest/Android.mk
@@ -29,7 +29,11 @@
     $(call all-java-files-under, ../../common)
 
 
-LOCAL_STATIC_JAVA_LIBRARIES := android-support-test compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    android-support-test \
+    compatibility-device-util \
+    legacy-android-test \
+
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/net/app/Android.mk b/hostsidetests/net/app/Android.mk
index f094f3f..66adea7 100644
--- a/hostsidetests/net/app/Android.mk
+++ b/hostsidetests/net/app/Android.mk
@@ -23,6 +23,8 @@
 LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner ub-uiautomator \
         CtsHostsideNetworkTestsAidl
 
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsHostsideNetworkTestsApp
diff --git a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/Android.mk b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/Android.mk
index 9d0d001..0f30b3b 100644
--- a/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/Android.mk
+++ b/hostsidetests/os/test-apps/StaticSharedLibConsumerApp1/Android.mk
@@ -24,7 +24,8 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     android-support-test \
-    compatibility-device-util
+    compatibility-device-util \
+    legacy-android-test
 
 LOCAL_RES_LIBRARIES := CtsStaticSharedLibProviderApp1
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/launcher1/Android.mk b/hostsidetests/shortcuts/deviceside/backup/launcher1/Android.mk
index d6077a4..dae8ba0 100644
--- a/hostsidetests/shortcuts/deviceside/backup/launcher1/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/launcher1/Android.mk
@@ -35,7 +35,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/launcher2/Android.mk b/hostsidetests/shortcuts/deviceside/backup/launcher2/Android.mk
index 8f124a0..29e238a 100644
--- a/hostsidetests/shortcuts/deviceside/backup/launcher2/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/launcher2/Android.mk
@@ -35,7 +35,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/launcher3/Android.mk b/hostsidetests/shortcuts/deviceside/backup/launcher3/Android.mk
index 9883e5c..8155d8f 100644
--- a/hostsidetests/shortcuts/deviceside/backup/launcher3/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/launcher3/Android.mk
@@ -35,7 +35,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/launcher4new/Android.mk b/hostsidetests/shortcuts/deviceside/backup/launcher4new/Android.mk
index 856ff1f..0b162fc 100644
--- a/hostsidetests/shortcuts/deviceside/backup/launcher4new/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/launcher4new/Android.mk
@@ -35,7 +35,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/launcher4old/Android.mk b/hostsidetests/shortcuts/deviceside/backup/launcher4old/Android.mk
index 0147dd6..587fd41 100644
--- a/hostsidetests/shortcuts/deviceside/backup/launcher4old/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/launcher4old/Android.mk
@@ -35,7 +35,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher1/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher1/Android.mk
index 72da903..db5a12c 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher1/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher1/Android.mk
@@ -35,7 +35,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher2/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher2/Android.mk
index 286dded..efa2116 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher2/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher2/Android.mk
@@ -35,7 +35,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher3/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher3/Android.mk
index f1421d1..7852b0c 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher3/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher3/Android.mk
@@ -35,7 +35,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher4new/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher4new/Android.mk
index ace1afe..e507530 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher4new/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher4new/Android.mk
@@ -37,7 +37,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher4new_nobackup/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher4new_nobackup/Android.mk
index 75a025b..26b1f11 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher4new_nobackup/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher4new_nobackup/Android.mk
@@ -37,7 +37,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher4new_nomanifest/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher4new_nomanifest/Android.mk
index 4a712f7..7c22ff3 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher4new_nomanifest/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher4new_nomanifest/Android.mk
@@ -37,7 +37,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher4new_wrongkey/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher4new_wrongkey/Android.mk
index 9d4739e..72654d8 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher4new_wrongkey/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher4new_wrongkey/Android.mk
@@ -37,7 +37,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_CERTIFICATE := cts/hostsidetests/appsecurity/certs/cts-testkey1
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher4old/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher4old/Android.mk
index b7187f0..3aba422 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher4old/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher4old/Android.mk
@@ -35,7 +35,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/backup/publisher4old_nomanifest/Android.mk b/hostsidetests/shortcuts/deviceside/backup/publisher4old_nomanifest/Android.mk
index 537c811..b1536bf 100644
--- a/hostsidetests/shortcuts/deviceside/backup/publisher4old_nomanifest/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/backup/publisher4old_nomanifest/Android.mk
@@ -37,7 +37,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/multiuser/Android.mk b/hostsidetests/shortcuts/deviceside/multiuser/Android.mk
index 619bdfe..6b484a9 100644
--- a/hostsidetests/shortcuts/deviceside/multiuser/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/multiuser/Android.mk
@@ -37,7 +37,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/shortcuts/deviceside/upgrade/Android.mk b/hostsidetests/shortcuts/deviceside/upgrade/Android.mk
index ae0bf75..b3e1d7f 100644
--- a/hostsidetests/shortcuts/deviceside/upgrade/Android.mk
+++ b/hostsidetests/shortcuts/deviceside/upgrade/Android.mk
@@ -41,7 +41,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
@@ -72,7 +73,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/hostsidetests/ui/appA/Android.mk b/hostsidetests/ui/appA/Android.mk
index 7da5606..85b1c5e 100644
--- a/hostsidetests/ui/appA/Android.mk
+++ b/hostsidetests/ui/appA/Android.mk
@@ -20,7 +20,11 @@
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    compatibility-device-util \
+    ctstestrunner \
+    legacy-android-test \
+
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/hostsidetests/ui/appB/Android.mk b/hostsidetests/ui/appB/Android.mk
index 07e2858..d993b7c 100644
--- a/hostsidetests/ui/appB/Android.mk
+++ b/hostsidetests/ui/appB/Android.mk
@@ -20,7 +20,11 @@
 
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    compatibility-device-util \
+    ctstestrunner \
+    legacy-android-test \
+
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/hostsidetests/webkit/app/Android.mk b/hostsidetests/webkit/app/Android.mk
index 60e9f3f..ad17725 100644
--- a/hostsidetests/webkit/app/Android.mk
+++ b/hostsidetests/webkit/app/Android.mk
@@ -27,6 +27,8 @@
     ctstestserver \
     ctstestrunner
 
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+
 # When built, explicitly put it in the data partition.
 #LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
diff --git a/libs/deviceutillegacy/Android.mk b/libs/deviceutillegacy/Android.mk
index f169ca8..aa8255e 100644
--- a/libs/deviceutillegacy/Android.mk
+++ b/libs/deviceutillegacy/Android.mk
@@ -18,8 +18,9 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
-    junit \
-    legacy-android-test
+    junit
+
+LOCAL_JAVA_LIBRARIES := android.test.base
 
 LOCAL_SRC_FILES := \
     $(call all-java-files-under, src)
diff --git a/tests/JobScheduler/Android.mk b/tests/JobScheduler/Android.mk
index be74d32..fa6a5d1 100755
--- a/tests/JobScheduler/Android.mk
+++ b/tests/JobScheduler/Android.mk
@@ -24,6 +24,8 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ub-uiautomator android-support-test
 
+LOCAL_JAVA_LIBRARIES := android.test.base
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_SRC_FILES += $(call all-java-files-under, JobTestApp/src)
 
diff --git a/tests/JobScheduler/jobperm/Android.mk b/tests/JobScheduler/jobperm/Android.mk
index f54f8d6..5c9b835 100644
--- a/tests/JobScheduler/jobperm/Android.mk
+++ b/tests/JobScheduler/jobperm/Android.mk
@@ -21,6 +21,7 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
+    legacy-android-test \
 
 LOCAL_SRC_FILES := \
     $(call all-java-files-under, src) \
diff --git a/tests/JobScheduler/shareduid/Android.mk b/tests/JobScheduler/shareduid/Android.mk
index ac4d8b3..c851fba 100644
--- a/tests/JobScheduler/shareduid/Android.mk
+++ b/tests/JobScheduler/shareduid/Android.mk
@@ -21,6 +21,7 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
+    legacy-android-test \
 
 LOCAL_SRC_FILES := \
     $(call all-java-files-under, src) \
diff --git a/tests/admin/Android.mk b/tests/admin/Android.mk
index 24fdda3..73de82d 100644
--- a/tests/admin/Android.mk
+++ b/tests/admin/Android.mk
@@ -23,6 +23,8 @@
 LOCAL_STATIC_JAVA_LIBRARIES := \
     ctstestrunner mockito-target-minus-junit4
 
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsAdminTestCases
diff --git a/tests/app/app2/Android.mk b/tests/app/app2/Android.mk
index 304f79e..45cab18 100644
--- a/tests/app/app2/Android.mk
+++ b/tests/app/app2/Android.mk
@@ -20,6 +20,7 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
+    legacy-android-test \
 
 LOCAL_SRC_FILES := \
     ../app/src/android/app/stubs/LocalService.java
diff --git a/tests/backup/app/fullbackup/Android.mk b/tests/backup/app/fullbackup/Android.mk
index ac53252..29e3577 100644
--- a/tests/backup/app/fullbackup/Android.mk
+++ b/tests/backup/app/fullbackup/Android.mk
@@ -29,6 +29,7 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
-    ctstestrunner
+    ctstestrunner \
+    legacy-android-test
 
 include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/backup/app/keyvalue/Android.mk b/tests/backup/app/keyvalue/Android.mk
index 3c36f50..7857bae 100644
--- a/tests/backup/app/keyvalue/Android.mk
+++ b/tests/backup/app/keyvalue/Android.mk
@@ -29,6 +29,7 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
-    ctstestrunner
+    ctstestrunner \
+    legacy-android-test
 
 include $(BUILD_CTS_SUPPORT_PACKAGE)
diff --git a/tests/framework/base/windowmanager/alertwindowservice/Android.mk b/tests/framework/base/windowmanager/alertwindowservice/Android.mk
index c012a65..436c3bc 100644
--- a/tests/framework/base/windowmanager/alertwindowservice/Android.mk
+++ b/tests/framework/base/windowmanager/alertwindowservice/Android.mk
@@ -20,6 +20,7 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
+    legacy-android-test \
 
 LOCAL_SRC_FILES := \
     $(call all-java-files-under, src) \
diff --git a/tests/leanbackjank/app/Android.mk b/tests/leanbackjank/app/Android.mk
index 04c3d3f..c8c70b0 100644
--- a/tests/leanbackjank/app/Android.mk
+++ b/tests/leanbackjank/app/Android.mk
@@ -36,7 +36,8 @@
     ctstestrunner \
     ub-uiautomator \
     ub-janktesthelper \
-    glide
+    glide \
+    legacy-android-test
 
 LOCAL_STATIC_ANDROID_LIBRARIES := \
     android-support-v4 \
diff --git a/tests/tests/alarmclock/Android.mk b/tests/tests/alarmclock/Android.mk
index adfd51f..ddce6a4 100644
--- a/tests/tests/alarmclock/Android.mk
+++ b/tests/tests/alarmclock/Android.mk
@@ -23,6 +23,8 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := CtsAlarmClockCommon ctstestrunner compatibility-device-util
 
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsAlarmClockTestCases
diff --git a/tests/tests/assist/Android.mk b/tests/tests/assist/Android.mk
index 6aa818e..ea437c2 100644
--- a/tests/tests/assist/Android.mk
+++ b/tests/tests/assist/Android.mk
@@ -26,6 +26,8 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := CtsAssistCommon ctstestrunner compatibility-device-util
 
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsAssistTestCases
diff --git a/tests/tests/dpi/Android.mk b/tests/tests/dpi/Android.mk
index 8bb7d64..0e07bec 100644
--- a/tests/tests/dpi/Android.mk
+++ b/tests/tests/dpi/Android.mk
@@ -41,7 +41,9 @@
 # CTS tests, so drop it into a library that other tests can use.
 include $(CLEAR_VARS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := junit legacy-android-test
+LOCAL_STATIC_JAVA_LIBRARIES := junit
+
+LOCAL_JAVA_LIBRARIES := android.test.base
 
 LOCAL_SRC_FILES := src/android/dpi/cts/DefaultManifestAttributesTest.java
 
diff --git a/tests/tests/dpi2/Android.mk b/tests/tests/dpi2/Android.mk
index dcd2c0f..6ecfce3 100644
--- a/tests/tests/dpi2/Android.mk
+++ b/tests/tests/dpi2/Android.mk
@@ -20,8 +20,6 @@
 # We use the DefaultManifestAttributesTest from the android.cts.dpi package.
 LOCAL_STATIC_JAVA_LIBRARIES := android.cts.dpi ctstestrunner junit
 
-LOCAL_JAVA_LIBRARIES := legacy-android-test
-
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsDpiTestCases2
diff --git a/tests/tests/externalservice/service/Android.mk b/tests/tests/externalservice/service/Android.mk
index 9fc0033..c151f3b 100644
--- a/tests/tests/externalservice/service/Android.mk
+++ b/tests/tests/externalservice/service/Android.mk
@@ -21,7 +21,12 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := CtsExternalServiceCommon ctstestrunner compatibility-device-util
+LOCAL_STATIC_JAVA_LIBRARIES := \
+    CtsExternalServiceCommon \
+    ctstestrunner \
+    compatibility-device-util \
+    legacy-android-test \
+
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
diff --git a/tests/tests/mediastress/Android.mk b/tests/tests/mediastress/Android.mk
index 0213c00..9316e85 100644
--- a/tests/tests/mediastress/Android.mk
+++ b/tests/tests/mediastress/Android.mk
@@ -28,6 +28,8 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
 
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+
 LOCAL_HOST_SHARED_LIBRARIES := compatibility-device-media-preconditions
 
 LOCAL_JNI_SHARED_LIBRARIES := libctsmediastress_jni libnativehelper_compat_libc++
diff --git a/tests/tests/openglperf/Android.mk b/tests/tests/openglperf/Android.mk
index 7669204..a3ab906 100644
--- a/tests/tests/openglperf/Android.mk
+++ b/tests/tests/openglperf/Android.mk
@@ -26,6 +26,8 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner compatibility-device-util
 
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+
 LOCAL_JNI_SHARED_LIBRARIES := libctsopenglperf_jni libnativehelper_compat_libc++
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
diff --git a/tests/tests/provider/Android.mk b/tests/tests/provider/Android.mk
index d4b3e99..6effdfa 100644
--- a/tests/tests/provider/Android.mk
+++ b/tests/tests/provider/Android.mk
@@ -28,7 +28,7 @@
 # Tag this module as a cts test artifact
 LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
 
-LOCAL_JAVA_LIBRARIES := android.test.mock legacy-android-test telephony-common
+LOCAL_JAVA_LIBRARIES := android.test.mock android.test.base android.test.runner telephony-common
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     android-support-v4 \
diff --git a/tests/tests/selinux/selinuxTargetSdk/Android.mk b/tests/tests/selinux/selinuxTargetSdk/Android.mk
index a0923ee..052514a 100755
--- a/tests/tests/selinux/selinuxTargetSdk/Android.mk
+++ b/tests/tests/selinux/selinuxTargetSdk/Android.mk
@@ -21,7 +21,6 @@
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
     ctstestrunner
-LOCAL_JAVA_LIBRARIES := legacy-android-test
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 LOCAL_PACKAGE_NAME := CtsSelinuxTargetSdkTestCases
 LOCAL_SDK_VERSION := current
diff --git a/tests/tests/shortcutmanager/packages/launchermanifest/Android.mk b/tests/tests/shortcutmanager/packages/launchermanifest/Android.mk
index 5774466..b810801 100644
--- a/tests/tests/shortcutmanager/packages/launchermanifest/Android.mk
+++ b/tests/tests/shortcutmanager/packages/launchermanifest/Android.mk
@@ -33,7 +33,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
@@ -63,7 +64,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
@@ -93,7 +95,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/tests/tests/shortcutmanager/packages/launchermanifest_nonshared/Android.mk b/tests/tests/shortcutmanager/packages/launchermanifest_nonshared/Android.mk
index 0d954e2..93f30eb 100644
--- a/tests/tests/shortcutmanager/packages/launchermanifest_nonshared/Android.mk
+++ b/tests/tests/shortcutmanager/packages/launchermanifest_nonshared/Android.mk
@@ -32,7 +32,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/tests/tests/shortcutmanager/packages/packagemanifest/Android.mk b/tests/tests/shortcutmanager/packages/packagemanifest/Android.mk
index b8741f2..ddfbe76 100644
--- a/tests/tests/shortcutmanager/packages/packagemanifest/Android.mk
+++ b/tests/tests/shortcutmanager/packages/packagemanifest/Android.mk
@@ -32,7 +32,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
@@ -62,7 +63,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
@@ -92,7 +94,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/Android.mk b/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/Android.mk
index ac09355..e8b5024 100644
--- a/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/Android.mk
+++ b/tests/tests/shortcutmanager/packages/packagemanifest_nonshared/Android.mk
@@ -32,7 +32,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/tests/tests/shortcutmanager/throttling/Android.mk b/tests/tests/shortcutmanager/throttling/Android.mk
index 62f959e..79b3db8 100644
--- a/tests/tests/shortcutmanager/throttling/Android.mk
+++ b/tests/tests/shortcutmanager/throttling/Android.mk
@@ -35,7 +35,8 @@
     compatibility-device-util \
     ctstestrunner \
     ub-uiautomator \
-    ShortcutManagerTestUtils
+    ShortcutManagerTestUtils \
+    legacy-android-test
 
 LOCAL_SDK_VERSION := current
 
diff --git a/tests/tests/voiceinteraction/Android.mk b/tests/tests/voiceinteraction/Android.mk
index b83f4e9..8641e76 100644
--- a/tests/tests/voiceinteraction/Android.mk
+++ b/tests/tests/voiceinteraction/Android.mk
@@ -23,6 +23,8 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := CtsVoiceInteractionCommon ctstestrunner compatibility-device-util
 
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsVoiceInteractionTestCases
diff --git a/tests/tests/webkit/Android.mk b/tests/tests/webkit/Android.mk
index c56f00e..5612c53 100644
--- a/tests/tests/webkit/Android.mk
+++ b/tests/tests/webkit/Android.mk
@@ -21,7 +21,11 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_JAVA_LIBRARIES := android.test.runner org.apache.http.legacy
+LOCAL_JAVA_LIBRARIES := \
+    android.test.runner \
+    org.apache.http.legacy \
+    android.test.base \
+
 
 LOCAL_STATIC_JAVA_LIBRARIES := \
     compatibility-device-util \
diff --git a/tests/ui/Android.mk b/tests/ui/Android.mk
index 53ae77e..b2a169e 100644
--- a/tests/ui/Android.mk
+++ b/tests/ui/Android.mk
@@ -22,6 +22,8 @@
 
 LOCAL_STATIC_JAVA_LIBRARIES := compatibility-device-util ctstestrunner
 
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
+
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_PACKAGE_NAME := CtsUiDeviceTestCases
diff --git a/tools/cts-reference-app-lib/Android.mk b/tools/cts-reference-app-lib/Android.mk
index 8f6039d..6beef3a 100644
--- a/tools/cts-reference-app-lib/Android.mk
+++ b/tools/cts-reference-app-lib/Android.mk
@@ -24,7 +24,9 @@
 # and when built explicitly put it in the data partition
 LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
 
-LOCAL_STATIC_JAVA_LIBRARIES := legacy-android-test junit
+LOCAL_STATIC_JAVA_LIBRARIES := junit
+
+LOCAL_JAVA_LIBRARIES := android.test.runner.stubs
 
 LOCAL_SDK_VERSION := current