Home  >  Article  >  Java  >  Why Do I Get the Error 'Android:exported Needs to Be Explicitly Specified for '?

Why Do I Get the Error 'Android:exported Needs to Be Explicitly Specified for '?

Susan Sarandon
Susan SarandonOriginal
2024-11-10 08:33:02503browse

Why Do I Get the Error

Android:exported needs to be explicitly specified for <**activity**>. 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. main manifest (this file)

The above error message indicates that one or more <**activity**> elements in your AndroidManifest.xml file are missing the **android:exported** attribute. In Android 12 and higher, all <**activity**> elements must have an explicit value for the **android:exported** attribute, even if the default value (**false**) is desired.

To fix this error, you need to add the **android:exported** attribute to all <**activity**> elements in your manifest file. The value of the attribute should be **true** if the activity should be exported, or **false** if it should not be exported.

Here is an example of an <**activity**> element with the **android:exported** attribute set to **false**:

<activity
    android:name=".MainActivity"
    android:exported="false" />

Once you have added the **android:exported** attribute to all <**activity**> elements in your manifest file, you should be able to build your app without errors.

Here are some additional resources that may be helpful:

  • [AndroidManifest.xml File](https://developer.android.com/guide/topics/manifest/manifest-intro)
  • [<**activity**> Element](https://developer.android.com/guide/topics/manifest/activity-element)
  • [Exporting Activities](https://developer.android.com/guide/topics/manifest/activity-element#exporting)

The above is the detailed content of Why Do I Get the Error 'Android:exported Needs to Be Explicitly Specified for '?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn