Behavior changes: Apps targeting Android 11

Like earlier releases, Android 11 includes behavior changes that may affect your app. The following behavior changes apply exclusively to apps that are targeting Android 11 or higher. If your app sets targetSdkVersion to 30, you should modify your app to support these behaviors properly, where applicable.

Be sure to also review the list of behavior changes that affect all apps running on Android 11.

Privacy

Android 11 introduces changes and restrictions to enhance user privacy, including the following:

  • Scoped storage enforcement: Access into external storage directories is limited to an app-specific directory and specific types of media that the app has created.
  • Permissions auto-reset: If users haven't interacted with an app for a few months, the system auto-resets the app's sensitive permissions.
  • Background location access: Users must be directed to system settings in order to grant the background location permission to apps.
  • Package visibility: When an app queries for the list of installed apps on the device, the returned list is filtered.

To learn more, see the Privacy page.

Compressed resource files

Change details

Change Name: RESOURCES_ARSC_COMPRESSED

Change ID: 132742131

How to toggle

As you test your app's compatibility with Android 11, you can toggle this change on or off using the following ADB commands:

adb shell am compat enable (132742131|RESOURCES_ARSC_COMPRESSED) PACKAGE_NAME
adb shell am compat disable (132742131|RESOURCES_ARSC_COMPRESSED) PACKAGE_NAME

For more information about the compatibility framework and toggling changes, see Test your app's compatibility with Android 11.

Apps that target Android 11 (API level 30) or higher can't be installed if they contain a compressed resources.arsc file or if this file is not aligned on a 4-byte boundary. This file cannot by memory-mapped by the system if either of these conditions is present. Resources tables that cannot be memory-mapped must be read into a buffer in RAM resulting in unnecessary memory pressure on the system and greatly increased device RAM usage.

Connectivity

Restricted read access to APN database

Change details

Change Name: APN_READING_PERMISSION_CHANGE_ID

Change ID: 124107808

How to toggle

As you test your app's compatibility with Android 11, you can toggle this change on or off using the following ADB commands:

adb shell am compat enable (124107808|APN_READING_PERMISSION_CHANGE_ID) PACKAGE_NAME
adb shell am compat disable (124107808|APN_READING_PERMISSION_CHANGE_ID) PACKAGE_NAME

For more information about the compatibility framework and toggling changes, see Test your app's compatibility with Android 11.

Apps that target Android 11 now require the Manifest.permission.WRITE_APN_SETTINGS privileged permission to read or access the Telephony provider APN database. Attempting to access the APN database without this permission generates a security exception.

Security

Heap pointer tagging

Change details

Change Name: NATIVE_HEAP_POINTER_TAGGING

Change ID: 135754954

How to toggle

As you test your app's compatibility with Android 11, you can toggle this change on or off using the following ADB commands:

adb shell am compat enable (135754954|NATIVE_HEAP_POINTER_TAGGING) PACKAGE_NAME
adb shell am compat disable (135754954|NATIVE_HEAP_POINTER_TAGGING) PACKAGE_NAME

For more information about the compatibility framework and toggling changes, see Test your app's compatibility with Android 11.

Heap pointers now have a non-zero tag in the most significant byte (MSB). Applications that use pointers incorrectly, including those that modify the MSB, can now crash or experience other issues. This change is necessary to support future hardware with ARM Memory Tagging Extension (MTE) enabled. To learn more, see Tagged Pointers.

To disable this feature, see the allowNativeHeapPointerTagging manifest documentation.

Custom toast views are blocked

Change details

Change Name: CHANGE_BACKGROUND_CUSTOM_TOAST_BLOCK

Change ID: 128611929

How to toggle

As you test your app's compatibility with Android 11, you can toggle this change on or off using the following ADB commands:

adb shell am compat enable (128611929|CHANGE_BACKGROUND_CUSTOM_TOAST_BLOCK) PACKAGE_NAME
adb shell am compat disable (128611929|CHANGE_BACKGROUND_CUSTOM_TOAST_BLOCK) PACKAGE_NAME

For more information about the compatibility framework and toggling changes, see Test your app's compatibility with Android 11.

As of Android 11, custom toast views are deprecated. If your app targets Android 11, toasts that contain custom views are blocked when posted from the background. Custom toast views continue to work if you target an older version of Android, but their use is discouraged.

It's recommended that you use snackbars instead where possible. If your app's use case prevents you from using snackbars, such as when you need to send the user a message while your app is in the background, you can still use text toasts because they aren't restricted by the new behavior change.

To learn more about these changes, see Updates to toasts in Android 11.

APK Signature Scheme v2 now required

Apps that target Android 11 (API level 30) that are currently only signed using APK Signature Scheme v1 must now also be signed using APK Signature Scheme v2 or higher. Users can't install or update apps that are only signed with APK Signature Scheme v1 on devices that run Android 11.

To verify that your app is being signed with APK Signature Scheme v2 or higher, you can use either Android Studio, or the apksigner tool on the command line.

Accessibility

Declare accessibility button usage in metadata file

Change details

Change Name: REQUEST_ACCESSIBILITY_BUTTON_CHANGE

Change ID: 136293963

How to toggle

As you test your app's compatibility with Android 11, you can toggle this change on or off using the following ADB commands:

adb shell am compat enable (136293963|REQUEST_ACCESSIBILITY_BUTTON_CHANGE) PACKAGE_NAME
adb shell am compat disable (136293963|REQUEST_ACCESSIBILITY_BUTTON_CHANGE) PACKAGE_NAME

For more information about the compatibility framework and toggling changes, see Test your app's compatibility with Android 11.

Starting in Android 11, your accessibility service cannot declare an association with the system's accessibility button at runtime. If you append AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON to the flags property of an AccessibilityServiceInfo object, the framework doesn't pass accessibility button callback events to your service.

Instead, declare your accessibility service's association with the accessibility button using the flagRequestAccessibilityButton flag in your accessibility service metadata file, typically res/raw/accessibilityservice.xml.

Camera

Media intent actions require system default camera

Starting in Android 11, only pre-installed system camera apps can respond to the following intent actions:

If more than one pre-installed system camera app is available, the system presents a dialog for the user to select an app. If you want your app to use a specific third-party camera app to capture images or videos on its behalf, you can make these intents explicit by setting a package name or component for the intent.

Firebase

Firebase JobDispatcher and GCMNetworkManager

If your app targets API level 30 or higher, Firebase JobDispatcher and GcmNetworkManager API calls are disabled on devices running Android 6.0 (API level 23) or higher. For migration information, see Migrating from Firebase JobDispatcher to WorkManager and Migrating from GCMNetworkManager to WorkManager.

Device-to-device file transfer

If your app targets Android 11, you can no longer disable device-to-device migration of your app's files using the allowBackup attribute. The system automatically allows this functionality.

However, you can still disable cloud-based backup and restore of your app's files by setting the allowBackup attribute to false, even if your app targets Android 11.