Deprecated API
Contents
-
ClassDescriptionNative Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.only works when used in conjunction with the deprecated
LooperMode.LEGACY
mode. Consider using guava'sMoreExecutors#directExecutor()
orPausedExecutorService
orInlineExecutorService
.Provide an implementation ofjavax.inject.Provider<Config>
. This class will be removed in Robolectric 4.3.UseMatrixCursor
instead.UseMatrixCursor
instead.The invoke-dynamic case has been moved to ClassInstrumentor. Classes previously extending this class should extendClassInstrumentor
directly.This method of configuration will be removed in a forthcoming release. Build systems should follow http://robolectric.org/build-system-integration/ to provide integration with Robolectric.use LooperMode.Mode.INSTRUMENTATION_TEST insteadDon't put more stuff here.Don't put more stuff here.useDefaultSdkPicker
instead.UseGnssStatus.Builder
instead where possible.Please useRobolectric.buildFragment(Class)
instead. This will be removed in a forthcoming release,This class can introduce deadlocks, since its lock is held while invoking run().
-
FieldDescriptionNot currently supported or used.Not currently supported or used.Please use {#getApplication} instead. Accessing this field directly is inherently incompatible with
LazyApplication
and Robolectric makes no guarantees if a test *modifies* this field during execution.UseRuntimeEnvironment.getApplication()
instead. Note that unlike the alternative, this field is inherently incompatible withLazyApplication
. This field may be removed in a later releaseUseShadowTelecomManager.CallRecord.extras
instead.
-
MethodDescriptionUse the appropriate builder in
Robolectric
instead. This method will be removed in Robolectric 3.6.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureIf you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureIf you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configure builds http://robolectric.org/getting-started/To change your package name please override the applicationId in your build system. Changing package name here is broken as the package name will no longer match the package name encoded in the arsc resources file. If you are looking to simulate another application you can create another applications Context usingContext.createPackageContext(String, int)
. Note that you must add this package toShadowPackageManager.addPackage(android.content.pm.PackageInfo)
first.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configuredo not useRobolectric will never ask for a dependency composed of more than one artifact, so this method isn't necessary.Do not use.Do not use.- UsePackageItemData.getName()
instead.UseNativeObjRegistry.register(Object)
instead.UseNativeObjRegistry.unregister(long)
instead.UseFs.fromUrl(String)
instead.UseFile.toPath()
instead.useFs.externalize(Path)
instead.usePath.resolve(Path)
instead.Figure something else out.UseConfiguration.screenWidthDp
instead.UseConfiguration.smallestScreenWidthDp
instead.UseConfiguration.orientation
instead.UseBuild.VERSION.SDK_INT
instead.UseConfiguration.screenWidthDp
instead.UseConfiguration.smallestScreenWidthDp
instead.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.Native Fragments have been deprecated in Android P. Android encourages developers to use androidx fragments, to test these use FragmentScenario.useandroidx.test.core.app.ActivityScenario
Provide a service implementation ofGlobalConfigProvider
instead. This method will be removed in Robolectric 4.3.Do not use.Use PAUSED looper mode.Use PAUSED looper mode.Do not use.UseFakeHttp.getSentHttpRequestInfo(int)
instead. This method will be removed in Robolectric 4.13.UseFakeHttp.getSentHttpRequest(int)
instead. This method will be removed in Robolectric 4.13.UseActivityManager.getLockTaskModeState()
instead.Prefer using overload withShadowActivityManager.ApplicationExitInfoBuilder
do not usePrefer to useShadowAlarmManager.setAutoSchedule(boolean)
in combination with incrementing time to actually run alarms and test their side-effects.use PowerManager APIs insteaduse ShadowPowerManager.clearWakeLocksPlease useContext.getSystemService(Context.APPWIDGET_SERVICE)
intstead.UseBluetoothAdapter.getDefaultAdapter()
()} instead.UseshadowOf({@link ApplicationProvider#getApplicationContext()})
instead.UseShadowAlertDialog.getLatestAlertDialog()
instead.UseShadowDialog.getLatestDialog()
instead.UseShadowPopupMenu.getLatestPopupMenu()
instead.use ShadowPowerManager.getLatestWakeLockuse PackageManager.queryBroadcastReceivers insteaduse PackageManager.queryBroadcastReceivers insteadDo not depend on this method to override services as it will be removed in a future update. The preferered method is use the shadow of the corresponding service.Avoid use.Avoid use.use ShadowBitmap#getCreatedFromResId() instead.Use any of the BitmapFactory.decode methods with real image data.Use any of the BitmapFactory.decode methods with real image data.Use any of the BitmapFactory.decode methods with real image data.Use any of the BitmapFactory.decode methods with real image data.use real BluetoothLeAdvertiser insteadUse theLooperMode.Mode.PAUSED
looper andShadowChoreographer.getFrameDelay()
to configure the frame delay.Use theLooperMode.Mode.PAUSED
looper andShadowChoreographer.setFrameDelay(Duration)
to configure the frame delay.Use theLooperMode.Mode.PAUSED
looper instead.Use theLooperMode.Mode.PAUSED
looper andShadowChoreographer.setPaused(boolean)
andShadowChoreographer.setFrameDelay(Duration)
to configure the vsync event behavior.implementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadimplementation detail - use public Android APIs insteadThis method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
This method does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
This method affects all calls, and does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
This method affects all calls, and does not work withContentResolver.acquireContentProviderClient(android.net.Uri)
UseShadowCrossProfileApps.peekNextStartedActivity()
instead.This behavior is deprecated and will be removed in Robolectric 4.13.This behavior is deprecated and will be removed in Robolectric 4.13.This behavior is deprecated and will be removed in Robolectric 3.7.This method is deprecated and will be removed in Robolectric 4.13.useContextCompat.getDrawable(context, resourceId)
useShadowFingerprintManager.setDefaultFingerprints(int)
instead.Please add calls by adding a Call usingInCallService.InCallServiceBinder
.Please remove calls by invokingCall.disconnect()
.Use aHandler
instance to post to a looper.Use aHandler
instance to post to a looper.Do not test listeners, instead useShadowLocationManager.simulateLocation(Location)
and test the results of those listeners being invoked.Do not test listeners, instead useShadowLocationManager.simulateLocation(Location)
and test the results of those listeners being invoked.Do not test pending intents, instead useShadowLocationManager.simulateLocation(Location)
and test the results of those pending intent being invoked.Do not test pending intents, instead useShadowLocationManager.simulateLocation(Location)
and test the results of those pending intent being invoked.Do not test listeners, instead useShadowLocationManager.simulateLocation(Location)
and test the results of those listeners being invoked.UseShadowLocationManager.simulateGnssAntennaInfo(List)
instead.UseShadowLocationManager.simulateGnssStatus(GnssStatus)
instead.UseShadowLocationManager.simulateLocation(Location)
to update the last location for a provider.UseshadowOf({@link Looper#getMainLooper()})
instead.Use aHandler
instance to post to a looper.Use aHandler
instance to post to a looper.useMotionEvent.obtain()
orandroidx.test.core.view.MotionEventBuilder
to create a MotionEvent with desired data.useMotionEvent.obtain()
orMotionEventBuilder
to create a MotionEvent with desired datauseMotionEvent.obtain()
orandroidx.test.core.view.MotionEventBuilder#setPointerAction(int, int)
to create a MotionEvent with desired data.UseShadowPackageManager.installPackage(PackageInfo)
instead.useShadowPackageManager.addIntentFilterForComponent(android.content.ComponentName, android.content.IntentFilter, java.util.Map<android.content.ComponentName, java.util.List<android.content.IntentFilter>>)
instead and if the component doesn't exist add it using any ofShadowPackageManager.installPackage(android.content.pm.PackageInfo)
,ShadowPackageManager.addOrUpdateActivity(android.content.pm.ActivityInfo)
,ShadowPackageManager.addActivityIfNotPresent(android.content.ComponentName)
or their counterparts for other types of components.see the note onShadowPackageManager.addResolveInfoForIntent(Intent, ResolveInfo)
.see the note onShadowPackageManager.addResolveInfoForIntent(Intent, ResolveInfo)
.It is recommended to switch to androidx's AsyncTaskLoader, which provides an overridable getExecutor method.this method only exists to accommodate legacy tests with preexisting issues. Silently discarding exceptions is not recommended, and can lead to deadlocks.preferShadowPendingIntent.isActivity()
which was added toPendingIntent
in API 31 (Android S).preferShadowPendingIntent.isBroadcast()
which was added toPendingIntent
in API 31 (Android S).preferShadowPendingIntent.isForegroundService()
which was added toPendingIntent
in API 31 (Android S).preferShadowPendingIntent.isService()
which was added toPendingIntent
in API 31 (Android S).PreferShadowPowerManager.turnScreenOn(boolean)
instead.UseShadowPowerManager.turnScreenOn(boolean)
instead.use ScanResult() insteaduse ScanResult() insteadUseShadowSensor.newInstance(int)
to construct yourSensor
and add to theSensorManager
usingShadowSensorManager.addSensor(Sensor)
instead. This method will be removed at some point allowing us to use more of the realSensorManager
code.Use{@link SensorEventBuilder#newBuilder()}
instead.Use{@link SensorEventBuilder#newBuilder()}
instead.Use{@link SensorEventBuilder#newBuilder()}
instead.Don't call this method directly; instead, useSystem.nanoTime()
.API deprecated since Q, for testing, use setDefaultDialerPackage insteadAvoid using.Avoid using.for resetAllSimCountryIsosuse resetAllSimStates()TelephonyManager.getNetworkType()
was replaced withTelephonyManager.getDataNetworkType()
in Android N, and has been deprecated in Android R. Useinstead
.preferShadowUsbDeviceConnection.getOutgoingDataStream()
, which allows callers to know how much data has been read and when theUsbDeviceConnection
closes.use either addUser() or addProfile()useShadowUserManager.setUserSwitchability(int)
insteadUseShadowUserManager.addUser(int, String, int)
to create a demo user instead of changing default user flags.UseShadowUserManager.addUser(int, String, int)
to create a guest user instead of changing default user flags.UseShadowUserManager.addUser(int, String, int)
to create a linked user instead of changing default user flags.UseShadowUserManager.addUser(int, String, int)
to create a primary user instead of changing default user flags.useShadowUserManager#addUser()
insteadUseShadowUserManager.addUser(int, String, int)
to create a system user instead of changing default user flags.When possible, please use the real Android framework APIUserManager#setUserRestriction()
.- Please use Espresso for View interactions.Please use Espresso for view interactions- Please useandroidx.test.espresso.util.HumanReadables#describe(View)
- Please useandroidx.test.espresso.util.HumanReadables#describe(View)
- Please useandroidx.test.espresso.util.HumanReadables#describe(View)
- Please useandroidx.test.espresso.util.HumanReadables#describe(View)
Do not depend on this method as it will be removed in a future update. The preferred method is to populate a fake web history to use for going back.This is no longer set on T+ due to MEP as a single eUICC can have more than one ICCID tied to it. It is instead set viaUiccPortInfo
.UseUiccCardInfoBuilder.setPhysicalSlotIndex(int)
for Android T+ instead.This method is ambiguous in how it should behave when turning off constant idle. UseScheduler.setIdleState(IdleState)
instead to explicitly set the state.
-
Enum ConstantDescriptionuse LooperMode.PAUSEDLEGACY mode is inaccurate, has known bugs and will be removed in a future release.REALTISTIC is the default mode and does not need to be stated explicity.
-
Annotation Type ElementDescriptionIf you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureIf you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configureIf you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configure builds http://robolectric.org/getting-started/To change your package name please override the applicationId in your build system. Changing package name here is broken as the package name will no longer match the package name encoded in the arsc resources file. If you are looking to simulate another application you can create another applications Context using
Context.createPackageContext(String, int)
. Note that you must add this package toShadowPackageManager.addPackage(android.content.pm.PackageInfo)
first.If you are using at least Android Studio 3.0 alpha 5 or Bazel's android_local_test please migrate to the preferred way to configure
Path
instead.