Member-only story

Android 12: don’t forget to set android:exported on your activities, services, and receivers

Carlos Mota
3 min readJul 26, 2021

--

Android 12: don’t forget to set android:exported on your activities, services, and receivers cover

TL;DR

If you’re targeting Android 12, you need to set android:exported on each activity, service, and receiver on your AndroidManifest.xml file.

This recently happened to me while updating one of my apps to Android 12 (API 31). As I’d incremented the SDK version and hit build, the process failed with the error:

Error: Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

Note: the building process fails if you’re using Android Studio 2020.3.1 Canary 11 or later.

Introduction

The exported attribute is used to define if an activity, service, or receiver in your app is accessible and can be launched from an external application.

As a practical example, if you try to share a file you’ll see a set of applications available. Clicking on one of them will open the activity responsible to handle that file, which means that it’s declared on the Manifest with exported:true.

--

--

Carlos Mota
Carlos Mota

Written by Carlos Mota

👨‍💻, 🔭🌖, 🗺, 📸, 🏃‍💨, 🇵🇹, 🖖 - is this how I should use emojis? Also: https://www.cafonsomota.xyz/

Responses (1)