diff --git a/MODULE.bazel b/MODULE.bazel index 45c095240..c6667d8e9 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -52,7 +52,6 @@ maven.install( "androidx.concurrent:concurrent-futures-ktx:1.2.0", "androidx.core:core:1.6.0", "androidx.lifecycle:lifecycle-common:2.3.1", - "androidx.multidex:multidex:2.0.0", "androidx.tracing:tracing:1.1.0", "androidx.window:window-java:1.1.0", "androidx.window:window-core:1.1.0", diff --git a/build_extensions/android_library_test.bzl b/build_extensions/android_library_test.bzl index f886fa169..b280be928 100644 --- a/build_extensions/android_library_test.bzl +++ b/build_extensions/android_library_test.bzl @@ -10,7 +10,6 @@ def axt_android_library_test( data = [], device_list = None, manifest = None, - multidex = None, deps = [], **kwargs): """Placeholder for future instrumentation test support. diff --git a/build_extensions/mainDexClasses.rules b/build_extensions/mainDexClasses.rules deleted file mode 100644 index a81d1537b..000000000 --- a/build_extensions/mainDexClasses.rules +++ /dev/null @@ -1,20 +0,0 @@ - -keep public class * extends android.app.Instrumentation { - (); - } - -keep public class * extends android.app.Application { - (); - void attachBaseContext(android.content.Context); - } - -keep public class * extends android.app.backup.BackupAgent { - (); - } -# We need to keep all annotation classes because proguard does not trace annotation attribute -# it just filter the annotation attributes according to annotation classes it already kept. - -keep public class * extends java.lang.annotation.Annotation { - *; - } -# Keep old fashion tests in the main dex or they'll be silently ignored by InstrumentationTestRunner - -keep public class * extends android.test.InstrumentationTestCase { - (); - } - diff --git a/core/CHANGELOG.md b/core/CHANGELOG.md index f865ebbb0..e5c230db6 100644 --- a/core/CHANGELOG.md +++ b/core/CHANGELOG.md @@ -12,7 +12,7 @@ **API Changes** -* Update to minSdkVersion 23 +* Update to minSdkVersion 23 and remove all related logic for SDKs < 23 **Breaking API Changes** diff --git a/core/javatests/androidx/test/core/app/BUILD b/core/javatests/androidx/test/core/app/BUILD index 57fe42647..b6220c505 100644 --- a/core/javatests/androidx/test/core/app/BUILD +++ b/core/javatests/androidx/test/core/app/BUILD @@ -18,11 +18,9 @@ licenses(["notice"]) android_binary( name = "ActivityScenarioTest_target", manifest = "AndroidManifest_target.xml", - multidex = "legacy", deps = [ "//core/javatests/androidx/test/core/app/testing", "//core/javatests/androidx/test/core/app/testing:manifest", - "@maven//:androidx_multidex_multidex", ], ) diff --git a/espresso/CHANGELOG.md b/espresso/CHANGELOG.md index 2ea894b34..460ea3007 100644 --- a/espresso/CHANGELOG.md +++ b/espresso/CHANGELOG.md @@ -22,7 +22,7 @@ The following artifacts were released: **API Changes** -* Update to minSdkVersion 23 +* Update to minSdkVersion 23 and remove all related logic for SDKs < 23 **Breaking API Changes** diff --git a/espresso/device/CHANGELOG.md b/espresso/device/CHANGELOG.md index 40868ee00..15eb6a686 100644 --- a/espresso/device/CHANGELOG.md +++ b/espresso/device/CHANGELOG.md @@ -12,7 +12,7 @@ **API Changes** -* Update to minSdkVersion 23 +* Update to minSdkVersion 23 and remove all related logic for SDKs < 23 **Breaking API Changes** diff --git a/ext/junit/CHANGELOG.md b/ext/junit/CHANGELOG.md index 1e1d374e4..b32f51bd8 100644 --- a/ext/junit/CHANGELOG.md +++ b/ext/junit/CHANGELOG.md @@ -13,7 +13,7 @@ are released. **API Changes** -* Update to minSdkVersion 23 +* Update to minSdkVersion 23 and remove all related logic for SDKs < 23 **Breaking API Changes** diff --git a/ext/truth/CHANGELOG.md b/ext/truth/CHANGELOG.md index f4cbfd414..a963947b3 100644 --- a/ext/truth/CHANGELOG.md +++ b/ext/truth/CHANGELOG.md @@ -15,7 +15,7 @@ **API Changes** -* Update to minSdkVersion 23 +* Update to minSdkVersion 23 and remove all related logic for SDKs < 23 **Breaking API Changes** diff --git a/gradle-tests/espresso/accessibility/build.gradle b/gradle-tests/espresso/accessibility/build.gradle index e5f102df7..1d1c972d8 100644 --- a/gradle-tests/espresso/accessibility/build.gradle +++ b/gradle-tests/espresso/accessibility/build.gradle @@ -16,7 +16,6 @@ android { defaultConfig { minSdk rootProject.ext.minSdk targetSdk rootProject.ext.targetSdk - multiDexEnabled = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -44,7 +43,6 @@ android { } dependencies { - androidTestImplementation "androidx.multidex:multidex:2.0.0" androidTestImplementation libs.ext.junit androidTestImplementation libs.espresso.accessibility androidTestImplementation libs.espresso.core diff --git a/gradle-tests/espresso/contrib/build.gradle b/gradle-tests/espresso/contrib/build.gradle index 61b1909e1..da25de942 100644 --- a/gradle-tests/espresso/contrib/build.gradle +++ b/gradle-tests/espresso/contrib/build.gradle @@ -16,7 +16,6 @@ android { defaultConfig { minSdk rootProject.ext.minSdk targetSdk rootProject.ext.targetSdk - multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -46,7 +45,6 @@ android { } dependencies { - implementation "androidx.multidex:multidex:2.0.0" implementation "androidx.recyclerview:recyclerview:1.2.1" androidTestImplementation libs.espresso.contrib androidTestImplementation libs.ext.junit diff --git a/gradle-tests/espresso/device/build.gradle b/gradle-tests/espresso/device/build.gradle index 16ecdbe16..34b55e4ca 100644 --- a/gradle-tests/espresso/device/build.gradle +++ b/gradle-tests/espresso/device/build.gradle @@ -16,7 +16,6 @@ android { defaultConfig { minSdk rootProject.ext.minSdk targetSdk rootProject.ext.targetSdk - multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/gradle-tests/espresso/idling_resource/build.gradle b/gradle-tests/espresso/idling_resource/build.gradle index 18d00f844..f7e0eb6cd 100644 --- a/gradle-tests/espresso/idling_resource/build.gradle +++ b/gradle-tests/espresso/idling_resource/build.gradle @@ -16,7 +16,6 @@ android { defaultConfig { minSdk rootProject.ext.minSdk targetSdk rootProject.ext.targetSdk - multiDexEnabled true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } @@ -47,7 +46,6 @@ android { dependencies { implementation "androidx.annotation:annotation:1.7.0-beta01" - implementation "androidx.multidex:multidex:2.0.0" implementation libs.espresso.idlingresource androidTestImplementation libs.espresso.core androidTestImplementation libs.espresso.intents diff --git a/runner/android_junit_runner/CHANGELOG.md b/runner/android_junit_runner/CHANGELOG.md index 3955a65db..2556f4b2e 100644 --- a/runner/android_junit_runner/CHANGELOG.md +++ b/runner/android_junit_runner/CHANGELOG.md @@ -12,7 +12,7 @@ **API Changes** -* Update to minSdkVersion 23 +* Update to minSdkVersion 23 and remove all related logic for SDKs < 23 **Breaking API Changes** diff --git a/runner/android_junit_runner/java/androidx/test/internal/runner/ClassPathScanner.java b/runner/android_junit_runner/java/androidx/test/internal/runner/ClassPathScanner.java index bcd035421..557cb95bf 100644 --- a/runner/android_junit_runner/java/androidx/test/internal/runner/ClassPathScanner.java +++ b/runner/android_junit_runner/java/androidx/test/internal/runner/ClassPathScanner.java @@ -17,23 +17,16 @@ package androidx.test.internal.runner; import android.app.Instrumentation; -import android.content.pm.ApplicationInfo; -import android.os.Build.VERSION; -import android.util.Log; import dalvik.system.DexFile; -import java.io.File; import java.io.IOException; -import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Enumeration; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import java.util.regex.Pattern; /** * Finds class entries in provided paths to scan. @@ -205,46 +198,11 @@ public ClassPathScanner(Collection paths) { *

This will only scan for tests in the current Apk aka testContext. Note that this represents * a change from InstrumentationTestRunner where getTargetContext().getPackageCodePath() aka app * under test was also scanned. - * - *

This method will also handle cases where test apk is using multidex. */ public static Collection getDefaultClasspaths(Instrumentation instrumentation) { Collection classPaths = new ArrayList<>(); // add the test apk to claspath classPaths.add(instrumentation.getContext().getPackageCodePath()); - - if (VERSION.SDK_INT <= 20) { - // for platforms that do not support multidex natively, getPackageCodePath is not sufficient - - // each individual class.dex needs to be added. - Pattern extractedSecondaryName = Pattern.compile(".*\\.classes\\d+\\.zip"); - ApplicationInfo applicationInfo; - try { - // need to get target context's application info, because the test apk classes.dex are - // extracted there - applicationInfo = instrumentation.getTargetContext().getApplicationInfo(); - } catch (RuntimeException re) { - Log.w( - TAG, - "Failed to retrieve ApplicationInfo, no additional .dex files add for " - + "app under test", - re); - return Collections.emptyList(); - } - File root = new File(applicationInfo.dataDir); - ArrayDeque directoriesToScan = new ArrayDeque<>(); - directoriesToScan.add(root); - while (!directoriesToScan.isEmpty()) { - File directory = directoriesToScan.pop(); - for (File element : directory.listFiles()) { - if (element.isDirectory()) { - directoriesToScan.add(element); - } else if (element.isFile() - && extractedSecondaryName.matcher(element.getName()).matches()) { - classPaths.add(element.getPath()); - } - } - } - } return classPaths; } diff --git a/runner/android_junit_runner/java/androidx/test/runner/AndroidJUnitRunner.java b/runner/android_junit_runner/java/androidx/test/runner/AndroidJUnitRunner.java index b18461cc6..e8da8f6d0 100644 --- a/runner/android_junit_runner/java/androidx/test/runner/AndroidJUnitRunner.java +++ b/runner/android_junit_runner/java/androidx/test/runner/AndroidJUnitRunner.java @@ -17,9 +17,7 @@ package androidx.test.runner; import android.app.Activity; -import android.app.Application; import android.app.Instrumentation; -import android.content.Context; import android.os.Bundle; import android.os.Debug; import android.os.StrictMode; @@ -277,28 +275,14 @@ public class AndroidJUnitRunner extends MonitoringInstrumentation private static final String LOG_TAG = "AndroidJUnitRunner"; private Bundle arguments; - private InstrumentationResultPrinter instrumentationResultPrinter; + private final InstrumentationResultPrinter instrumentationResultPrinter = + new InstrumentationResultPrinter(); + ; private RunnerArgs runnerArgs; private TestEventClient testEventClient = TestEventClient.NO_OP_CLIENT; private final Set appExceptionsHandled = Collections.newSetFromMap(new WeakHashMap<>()); - @Override - public Application newApplication(ClassLoader cl, String className, Context context) - throws InstantiationException, IllegalAccessException, ClassNotFoundException { - Log.i(LOG_TAG, "newApplication " + className); - // install multidex as soon as possible - installMultidex(); - - if (instrumentationResultPrinter == null) { - // Create instrumentationResultPrinter as early as possible to assist with - // exception handling. InstrumentationResultPrinter use ConcurrentLinkedList, - // and as that is desugared (see b/246860430) it cannot be instantiated before - // multidex is loaded. - instrumentationResultPrinter = new InstrumentationResultPrinter(); - } - return super.newApplication(cl, className, context); - } /** {@inheritDoc} */ @Override @@ -307,16 +291,6 @@ public void onCreate(Bundle arguments) { Trace.beginSection("AndroidJUnitRunner#onCreate"); try { super.onCreate(arguments); - if (instrumentationResultPrinter == null) { - // Create instrumentationResultPrinter as early as possible to assist with - // exception handling. InstrumentationResultPrinter use ConcurrentLinkedList, - // and as that is desugared (see b/246860430) it cannot be instantiated before - // multidex is loaded. - // On API level <= 15, #onCreate is called earlier than #newApplication so it - // can be null, or if the system server itself is being instrumented. See - // MonitoringInstrumentation#onCreate. - instrumentationResultPrinter = new InstrumentationResultPrinter(); - } this.arguments = arguments; registerTestStorage(this.arguments); parseRunnerArgs(this.arguments); diff --git a/runner/android_junit_runner/javatests/androidx/test/internal/runner/BUILD b/runner/android_junit_runner/javatests/androidx/test/internal/runner/BUILD index 1e71fce31..3db662ada 100644 --- a/runner/android_junit_runner/javatests/androidx/test/internal/runner/BUILD +++ b/runner/android_junit_runner/javatests/androidx/test/internal/runner/BUILD @@ -1,14 +1,7 @@ # Description: Tests for Runner -load("@build_bazel_rules_android//android:rules.bzl", "android_binary") load("//build_extensions:android_library_test.bzl", "axt_android_library_test") -load("//build_extensions:axt_android_application_test.bzl", "axt_android_application_test") load("//build_extensions:axt_android_local_test.bzl", "axt_android_local_test") -load( - "//build_extensions:phone_devices.bzl", - "apis", - "devices", -) package( default_applicable_licenses = ["//:license"], @@ -17,76 +10,6 @@ package( licenses(["notice"]) -# test classpath scanning for a multidex self-instrumenting apk -axt_android_library_test( - name = "ClassPathScannerTest", - srcs = ["ClassPathScannerTest.java"], - # api 15 is flaky - # dex2oat fails on 24 + 25 for an unknown reason - device_list = devices(apis( - exclude_apis = [ - 24, - 25, - ], - )), - deps = [ - # include the large number of methods that will force classes off main dex - "//testapps/multidex_testapp/java/androidx/test/multidex/app:src", - "//core", - "//ext/junit", - "//runner/android_junit_runner", - "@maven//:junit_junit", - "@maven//:org_mockito_mockito_core", - "@maven//:com_google_truth_truth", - ], -) - -# # test classpath scanning for a multidex test apk, with a small app apk -android_binary( - name = "stub_target_app", - manifest = "//build_extensions:AndroidManifest_target_stub.xml", - manifest_values = { - "applicationId": "androidx.test.multidex", - }, - multidex = "legacy", - deps = [ - "//runner/android_junit_runner/javatests/androidx/test/testing/fixtures", - "@maven//:androidx_multidex_multidex", - ], -) - -axt_android_application_test( - name = "ClassPathScannerTest_stub_application_under_test", - srcs = ["ClassPathScannerTest.java"], - # TODO(b/116007991): enable more APIs once fixed - device_list = devices([ - 23, - 26, - 27, - 28, - 29, - 30, - ]), - instruments = ":stub_target_app", - manifest = "//build_extensions:AndroidManifest_instrumentation_test_template.xml", - manifest_values = { - "applicationId": "androidx.test.tests", - "instrumentationTargetPackage": "androidx.test.multidex", - "minSdkVersion": "21", - }, - multidex = "legacy", - deps = [ - # include the large number of methods that will force classes off main dex - "//testapps/multidex_testapp/java/androidx/test/multidex/app:src", - "//core", - "//ext/junit", - "//runner/android_junit_runner", - "@maven//:junit_junit", - "@maven//:org_mockito_mockito_core", - "@maven//:com_google_truth_truth", - ], -) - axt_android_library_test( name = "AndroidLogOnlyBuilderTest", srcs = [ diff --git a/runner/android_junit_runner/javatests/androidx/test/internal/runner/ClassPathScannerTest.java b/runner/android_junit_runner/javatests/androidx/test/internal/runner/ClassPathScannerTest.java deleted file mode 100644 index 1ce354800..000000000 --- a/runner/android_junit_runner/javatests/androidx/test/internal/runner/ClassPathScannerTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package androidx.test.internal.runner; - -import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; -import static com.google.common.truth.Truth.assertThat; - -import androidx.test.ext.junit.runners.AndroidJUnit4; -import androidx.test.internal.runner.ClassPathScanner.AcceptAllFilter; -import java.io.IOException; -import java.util.Set; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -/** - * Unit tests for {@link ClassPathScanner}. - * - *

is the instrumentation target, and is a multidex binary. Its critical this test is executed - * across APIs <=20 and newer APIs. - */ -@RunWith(AndroidJUnit4.class) -public class ClassPathScannerTest { - - private ClassPathScanner classPathScanner; - - @Before - public void setUp() throws Exception { - // scan the target aka app under test - classPathScanner = - new ClassPathScanner(ClassPathScanner.getDefaultClasspaths(getInstrumentation())); - } - - /** Verify that all classes are scanned in a multidex apk */ - @Test - public void multidex() throws IOException { - Set result = classPathScanner.getClassPathEntries(new AcceptAllFilter()); - assertThat(result) - .containsAtLeast( - "androidx.test.multidex.app.MultiDexTestClassA", - "androidx.test.multidex.app.MultiDexTestClassB", - "androidx.test.multidex.app.MultiDexTestClassC", - "androidx.test.multidex.app.MultiDexTestClassD", - "androidx.test.multidex.app.MultiDexApplication"); - - // ensure classes from binary under test are not included - // this relies on build adding "androidx.test.testing.fixtures.CustomTestFilter" to target app - // only - assertThat(result).doesNotContain("androidx.test.testing.fixtures.CustomTestFilter"); - } -} diff --git a/runner/android_test_orchestrator/CHANGELOG.md b/runner/android_test_orchestrator/CHANGELOG.md index d626d51d1..217b6b59d 100644 --- a/runner/android_test_orchestrator/CHANGELOG.md +++ b/runner/android_test_orchestrator/CHANGELOG.md @@ -14,7 +14,7 @@ **API Changes** -* Update to minSdkVersion 23 +* Update to minSdkVersion 23 and remove all related logic for SDKs < 23 **Breaking API Changes** diff --git a/runner/android_test_orchestrator/stubapp/BUILD b/runner/android_test_orchestrator/stubapp/BUILD index 554a6abe3..a6bbfc55a 100644 --- a/runner/android_test_orchestrator/stubapp/BUILD +++ b/runner/android_test_orchestrator/stubapp/BUILD @@ -20,7 +20,6 @@ android_binary( manifest_values = { "appVersion": ORCHESTRATOR_VERSION, }, - multidex = "native", # actually fits into one file, so skip main dex list proguard_specs = [ "//:proguard_binary.cfg", "proguard_binary.cfg", @@ -29,7 +28,6 @@ android_binary( deps = [ "//runner/android_junit_runner", "//runner/android_test_orchestrator", - "@maven//:androidx_multidex_multidex", "@maven//:junit_junit", ], ) diff --git a/runner/monitor/CHANGELOG.md b/runner/monitor/CHANGELOG.md index 28044f31c..60187df49 100644 --- a/runner/monitor/CHANGELOG.md +++ b/runner/monitor/CHANGELOG.md @@ -15,7 +15,7 @@ **API Changes** -* Update to minSdkVersion 23 +* Update to minSdkVersion 23 and remove all related logic for SDKs < 23 **Breaking API Changes** diff --git a/runner/monitor/java/androidx/test/api/current_public.txt b/runner/monitor/java/androidx/test/api/current_public.txt index 8f1e351b1..aa5e88e8b 100644 --- a/runner/monitor/java/androidx/test/api/current_public.txt +++ b/runner/monitor/java/androidx/test/api/current_public.txt @@ -115,8 +115,8 @@ package androidx.test.runner { method public android.app.Instrumentation.ActivityResult! execStartActivity(android.content.Context!, android.os.IBinder!, android.os.IBinder!, android.app.Fragment!, android.content.Intent!, int, android.os.Bundle!); method public android.app.Instrumentation.ActivityResult! execStartActivity(android.content.Context!, android.os.IBinder!, android.os.IBinder!, String!, android.content.Intent!, int, android.os.Bundle!); method protected String! getThreadState(); - method protected void installMultidex(); - method protected void installOldMultiDex(Class!) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException; + method @Deprecated protected void installMultidex(); + method @Deprecated protected void installOldMultiDex(Class!) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException, java.lang.NoSuchMethodException; method public void interceptActivityUsing(androidx.test.runner.intercepting.InterceptingActivityFactory!); method protected final boolean isPrimaryInstrProcess(); method @Deprecated protected boolean isPrimaryInstrProcess(String?); diff --git a/runner/monitor/java/androidx/test/runner/MonitoringInstrumentation.java b/runner/monitor/java/androidx/test/runner/MonitoringInstrumentation.java index 220180306..9164a80b0 100644 --- a/runner/monitor/java/androidx/test/runner/MonitoringInstrumentation.java +++ b/runner/monitor/java/androidx/test/runner/MonitoringInstrumentation.java @@ -141,12 +141,12 @@ public boolean queueIdle() { * Does initialization before creating the application. * *

Note, {@link #newApplication(ClassLoader, String, Context)} is called before {@link - * #onCreate(Bundle)} on API > 15. For API <= 15, {@link #onCreate(Bundle)} is called first. + * #onCreate(Bundle)}. */ @Override public Application newApplication(ClassLoader cl, String className, Context context) throws InstantiationException, IllegalAccessException, ClassNotFoundException { - installMultidexAndExceptionHandler(); + installExceptionHandler(); Application application = AppComponentFactoryRegistry.instantiateApplication(cl, className); if (application != null) { @@ -195,55 +195,18 @@ public Thread newThread(Runnable runnable) { useDefaultInterceptingActivityFactory(); } - protected void installMultidex() { - // Typically multidex is installed by inserting call at Application#attachBaseContext - // However instrumentation#onCreate is called before Application#attachBaseContext. Thus - // need to install it here, if its on classpath. - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - try { - Class multidex = getMultiDexClass(); - try { - Method installInstrumentation = - multidex.getDeclaredMethod("installInstrumentation", Context.class, Context.class); - installInstrumentation.invoke(null, getContext(), getTargetContext()); - } catch (NoSuchMethodException nsme) { - Log.w( - TAG, - "Could not find MultiDex.installInstrumentation. Calling MultiDex.install instead." - + " Is an old version of the multidex library being used? If test app is using" - + " multidex, classes might not be found"); - installOldMultiDex(multidex); - } - } catch (ClassNotFoundException ignored) { - Log.i(TAG, "No multidex."); - } catch (NoSuchMethodException nsme) { - Log.i(TAG, "No multidex.", nsme); - } catch (InvocationTargetException ite) { - throw new RuntimeException("multidex is available at runtime, but calling it failed.", ite); - } catch (IllegalAccessException iae) { - throw new RuntimeException("multidex is available at runtime, but calling it failed.", iae); - } - } - } - - private static Class getMultiDexClass() throws ClassNotFoundException { - try { - return Class.forName("androidx.multidex.MultiDex"); - } catch (ClassNotFoundException e) { - // check for support multidex - return Class.forName("android.support.multidex.MultiDex"); - } - } + /** + * @deprecated no-op: multidex is not necessary on SDKS >= 23 + */ + @Deprecated + protected void installMultidex() {} /** - * Perform application MultiDex installation only when instrumentation installation is not - * available. Called when MultiDex class is available but MultiDex.installInstrumentation is not. + * @deprecated no-op: multidex is not necessary on SDKS >= 23 */ + @Deprecated protected void installOldMultiDex(Class multidexClass) - throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { - Method install = multidexClass.getDeclaredMethod("install", Context.class); - install.invoke(null, getTargetContext()); - } + throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {} protected void specifyDexMakerCacheProperty() { // DexMaker uses heuristics to figure out where to store its temporary dex files @@ -290,10 +253,7 @@ private void setupDexmakerClassloader() { isDexmakerClassLoaderInitialized.set(Boolean.TRUE); } - private void installMultidexAndExceptionHandler() { - // Multidex must be installed early otherwise we could call into code that has - // landed in a different dex split. - installMultidex(); + private void installExceptionHandler() { // App could crash even before #onCreate(Bundle) method is called, e.g. during installing // content providers. // Registers a custom uncaught exception handler to shuttle back the exception to the diff --git a/runner/rules/CHANGELOG.md b/runner/rules/CHANGELOG.md index c952041b2..2c9475e84 100644 --- a/runner/rules/CHANGELOG.md +++ b/runner/rules/CHANGELOG.md @@ -12,7 +12,7 @@ **API Changes** -* Update to minSdkVersion 23 +* Update to minSdkVersion 23 and remove all related logic for SDKs < 23 **Breaking API Changes** diff --git a/services/AndroidManifest.xml b/services/AndroidManifest.xml index 643433af3..831bd4fb1 100644 --- a/services/AndroidManifest.xml +++ b/services/AndroidManifest.xml @@ -39,7 +39,6 @@ diff --git a/services/BUILD b/services/BUILD index 29c7a60d4..f5947762b 100644 --- a/services/BUILD +++ b/services/BUILD @@ -26,12 +26,10 @@ exports_files(["LICENSE"]) android_binary( name = "test_services", custom_package = "androidx.test.services", - main_dex_proguard_specs = ["//build_extensions:mainDexClasses.rules"], manifest = "AndroidManifest.xml", manifest_values = { "appVersion": SERVICES_VERSION, }, - multidex = "legacy", # to support android_fix_libs proguard_specs = [ "//:proguard_binary.cfg", "proguard_library.cfg", @@ -44,7 +42,6 @@ android_binary( "//services/speakeasy/java/androidx/test/services/speakeasy:protocol", "//services/speakeasy/java/androidx/test/services/speakeasy/server", "//services/storage/java/androidx/test/services/storage/provider:storage_content_providers", - "@maven//:androidx_multidex_multidex", ], ) diff --git a/services/CHANGELOG.md b/services/CHANGELOG.md index 8bb407f22..5f06775b0 100644 --- a/services/CHANGELOG.md +++ b/services/CHANGELOG.md @@ -12,7 +12,7 @@ **API Changes** -* Update to minSdkVersion 23 +* Update to minSdkVersion 23 and remove all related logic for SDKs < 23 **Breaking API Changes** diff --git a/services/speakeasy/javatests/androidx/test/services/speakeasy/client/testapp/BUILD b/services/speakeasy/javatests/androidx/test/services/speakeasy/client/testapp/BUILD index 0555ddddb..4c9e85c38 100644 --- a/services/speakeasy/javatests/androidx/test/services/speakeasy/client/testapp/BUILD +++ b/services/speakeasy/javatests/androidx/test/services/speakeasy/client/testapp/BUILD @@ -13,9 +13,7 @@ package( android_binary( name = "testapp", manifest = "AndroidManifest.xml", - multidex = "legacy", deps = [ "//services/speakeasy/java/androidx/test/services/speakeasy/server:speak_easy_service", - "@maven//:androidx_multidex_multidex", ], ) diff --git a/testapps/foldable_testapp/java/androidx/test/foldable/app/BUILD b/testapps/foldable_testapp/java/androidx/test/foldable/app/BUILD index a20868b25..eb1cae331 100644 --- a/testapps/foldable_testapp/java/androidx/test/foldable/app/BUILD +++ b/testapps/foldable_testapp/java/androidx/test/foldable/app/BUILD @@ -45,11 +45,9 @@ android_binary( assets = glob(["assets/**"]), assets_dir = "assets", manifest = "AndroidManifest.xml", - multidex = "legacy", resource_files = glob(["res/**"]), deps = [ ":lib", "//core:manifest", - "@maven//:androidx_multidex_multidex", ], ) diff --git a/testapps/multidex_testapp/java/androidx/test/multidex/app/AndroidManifest.xml b/testapps/multidex_testapp/java/androidx/test/multidex/app/AndroidManifest.xml deleted file mode 100644 index 00e660d00..000000000 --- a/testapps/multidex_testapp/java/androidx/test/multidex/app/AndroidManifest.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/testapps/multidex_testapp/java/androidx/test/multidex/app/BUILD b/testapps/multidex_testapp/java/androidx/test/multidex/app/BUILD deleted file mode 100644 index e4b42ce80..000000000 --- a/testapps/multidex_testapp/java/androidx/test/multidex/app/BUILD +++ /dev/null @@ -1,54 +0,0 @@ -load("@build_bazel_rules_android//android:rules.bzl", "android_binary") -load("//build_extensions:jetify.bzl", "jetify_android_library") - -# Description: -# Common library for testing inter and intra app communication via intents. -licenses(["notice"]) - -package( - default_applicable_licenses = ["//:license"], - default_testonly = 1, - default_visibility = ["//:__subpackages__"], -) - -# Genrule that creates a Java classes with 32768 methods -[genrule( - name = "MultiDexTestClass%s" % s, - outs = ["MultiDexTestClass%s.java" % s], - cmd = "echo 'package androidx.test.multidex.app;'>$@;" + - "echo 'public class MultiDexTestClass%s {'>>$@;" % s + - "for i in `seq 1 32768`;" + - "do echo 'public static int method'$$i'() {return 42;}'>>$@;" + - "done;" + - "echo '}'>>$@", -) for s in [ - "A", - "B", - "C", - "D", -]] - -jetify_android_library( - name = "src", - testonly = True, - srcs = [ - "MultiDexActivity.java", - "MultiDexApplication.java", - ":MultiDexTestClassA", - ":MultiDexTestClassB", - ":MultiDexTestClassC", - ":MultiDexTestClassD", - ], - jetify_sources = True, - deps = ["@maven//:androidx_multidex_multidex"], -) - -android_binary( - name = "multidex_testapp", - testonly = True, - main_dex_list = "main_dex_list.txt", - manifest = "AndroidManifest.xml", - multidex = "manual_main_dex", - resource_files = glob(["res/**"]), - deps = [":src"], -) diff --git a/testapps/multidex_testapp/java/androidx/test/multidex/app/MultiDexActivity.java b/testapps/multidex_testapp/java/androidx/test/multidex/app/MultiDexActivity.java deleted file mode 100644 index 36122d3bc..000000000 --- a/testapps/multidex_testapp/java/androidx/test/multidex/app/MultiDexActivity.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package androidx.test.multidex.app; - -import android.app.Activity; -import android.os.Bundle; -import android.widget.TextView; - -/** Launch of MultiDexActivity requires additional dex files on classpath. */ -public class MultiDexActivity extends Activity { - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - TextView textView = new TextView(this); - String message = - String.format( - "The answer is: %d\nThe answer is: %d\nThe answer is: %d\nThe answer is: %d\n" - + "The answer is: %d\nThe answer is: %d\nThe answer is: %d\nThe answer is: %d", - MultiDexTestClassA.method1(), - MultiDexTestClassA.method32768(), - MultiDexTestClassB.method1(), - MultiDexTestClassB.method32768(), - MultiDexTestClassC.method1(), - MultiDexTestClassC.method32768(), - MultiDexTestClassD.method1(), - MultiDexTestClassD.method32768()); - textView.setText(message); - setContentView(textView); - } -} diff --git a/testapps/multidex_testapp/java/androidx/test/multidex/app/MultiDexApplication.java b/testapps/multidex_testapp/java/androidx/test/multidex/app/MultiDexApplication.java deleted file mode 100644 index 26966e644..000000000 --- a/testapps/multidex_testapp/java/androidx/test/multidex/app/MultiDexApplication.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package androidx.test.multidex.app; - -import android.app.Application; -import android.content.Context; -import android.util.Log; -import androidx.multidex.MultiDex; - -/** MultiDexApplication is necessary to install / extract additional dex files */ -public class MultiDexApplication extends Application { - - private static final String TAG = MultiDexApplication.class.getSimpleName(); - - @Override - public void onCreate() { - super.onCreate(); - Log.i(TAG, ("MultiDex TestApp created")); - } - - @Override - protected void attachBaseContext(Context base) { - super.attachBaseContext(base); - MultiDex.install(this); - } -} diff --git a/testapps/multidex_testapp/java/androidx/test/multidex/app/main_dex_list.txt b/testapps/multidex_testapp/java/androidx/test/multidex/app/main_dex_list.txt deleted file mode 100644 index a33779d75..000000000 --- a/testapps/multidex_testapp/java/androidx/test/multidex/app/main_dex_list.txt +++ /dev/null @@ -1,3 +0,0 @@ -android/support/multidex/MultiDexApplication.class -androidx/test/multidex/app/MultiDexActivity.class -candroidx/test/multidex/app/MultiDexApplication.class \ No newline at end of file diff --git a/testapps/multidex_testapp/java/androidx/test/multidex/app/res/values/strings.xml b/testapps/multidex_testapp/java/androidx/test/multidex/app/res/values/strings.xml deleted file mode 100644 index 9e871e687..000000000 --- a/testapps/multidex_testapp/java/androidx/test/multidex/app/res/values/strings.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - MultiDex Test App - AndroidX MultiDex - \ No newline at end of file diff --git a/testapps/multiprocess_testapp/java/androidx/test/multiprocess/app/BUILD b/testapps/multiprocess_testapp/java/androidx/test/multiprocess/app/BUILD index 78204c024..8aa395d24 100644 --- a/testapps/multiprocess_testapp/java/androidx/test/multiprocess/app/BUILD +++ b/testapps/multiprocess_testapp/java/androidx/test/multiprocess/app/BUILD @@ -45,7 +45,6 @@ jetify_android_library( android_binary( name = "testapp", manifest = "AndroidManifest.xml", - multidex = "native", deps = [ ":lib", ], diff --git a/testapps/multiprocess_testapp/javatests/androidx/test/multiprocess/app/BUILD b/testapps/multiprocess_testapp/javatests/androidx/test/multiprocess/app/BUILD index bff7e7249..cd0a71807 100644 --- a/testapps/multiprocess_testapp/javatests/androidx/test/multiprocess/app/BUILD +++ b/testapps/multiprocess_testapp/javatests/androidx/test/multiprocess/app/BUILD @@ -26,7 +26,6 @@ axt_android_application_test( device_list = DEVICES, instruments = "//testapps/multiprocess_testapp/java/androidx/test/multiprocess/app:testapp", manifest = "AndroidManifest.xml", - multidex = "native", tags = ["integration"], deps = [ "//espresso/core/java/androidx/test/espresso", @@ -48,7 +47,6 @@ axt_android_application_test( device_list = DEVICES, instruments = "//testapps/multiprocess_testapp/java/androidx/test/multiprocess/app:testapp", manifest = "AndroidManifest_global.xml", - multidex = "native", tags = ["integration"], deps = [ "//core", @@ -68,7 +66,6 @@ axt_android_application_test( device_list = DEVICES, instruments = "//testapps/multiprocess_testapp/java/androidx/test/multiprocess/app:testapp", manifest = "AndroidManifest_idling.xml", - multidex = "native", tags = ["integration"], deps = [ "//espresso/core", @@ -86,7 +83,6 @@ axt_android_application_test( device_list = DEVICES, instruments = "//testapps/multiprocess_testapp/java/androidx/test/multiprocess/app:testapp", manifest = "AndroidManifest.xml", - multidex = "native", tags = ["integration"], deps = [ "//espresso/core/java/androidx/test/espresso", @@ -108,7 +104,6 @@ axt_android_application_test( device_list = DEVICES, instruments = "//testapps/multiprocess_testapp/java/androidx/test/multiprocess/app:testapp", manifest = "AndroidManifest_private.xml", - multidex = "native", tags = ["integration"], deps = [ "//espresso/core/java/androidx/test/espresso", @@ -127,7 +122,6 @@ axt_android_application_test( device_list = DEVICES, instruments = "//testapps/multiprocess_testapp/java/androidx/test/multiprocess/app:testapp", manifest = "AndroidManifest.xml", - multidex = "native", tags = ["integration"], deps = [ "//espresso/core/java/androidx/test/espresso", diff --git a/testapps/multiwindow_testapp/java/androidx/test/multiwindow/app/BUILD b/testapps/multiwindow_testapp/java/androidx/test/multiwindow/app/BUILD index 996bd6895..c986c14b6 100644 --- a/testapps/multiwindow_testapp/java/androidx/test/multiwindow/app/BUILD +++ b/testapps/multiwindow_testapp/java/androidx/test/multiwindow/app/BUILD @@ -44,11 +44,9 @@ android_binary( assets = glob(["assets/**"]), assets_dir = "assets", manifest = "AndroidManifest.xml", - multidex = "legacy", resource_files = glob(["res/**"]), deps = [ ":lib", "//core:manifest", - "@maven//:androidx_multidex_multidex", ], ) diff --git a/testapps/ui_testapp/java/androidx/test/ui/app/AndroidManifest.xml b/testapps/ui_testapp/java/androidx/test/ui/app/AndroidManifest.xml index b96932b45..8a90c0683 100644 --- a/testapps/ui_testapp/java/androidx/test/ui/app/AndroidManifest.xml +++ b/testapps/ui_testapp/java/androidx/test/ui/app/AndroidManifest.xml @@ -37,7 +37,6 @@