7

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode... lib\main.dart:1 C:\Users\lucks\OneDrive\Desktop\intern\android\app\src\debug\AndroidManifest.xml:15:9-22:20 Error: android:exported needs to be explicitly specified for element <receiver#com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver>. 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.

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:processDebugMainManifest'.

Manifest merger failed : android:exported needs to be explicitly specified for element <receiver#com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver>. 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.

  • Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

BUILD FAILED in 2s Exception: Gradle task assembleDebug failed with exit code 1 Exited (sigterm)

Image link is here https://i.stack.imgur.com/bUkHi.png I dont have that "flutterlocalnotifications" receiver in my manifest. So where do i add that explicit value???

Kishan Mevada
  • 662
  • 1
  • 6
  • 17
Sunil Thapa
  • 81
  • 1
  • 4
  • Does this answer your question? [Flutter: Targeting S+ (version 31 and above) requires that an explicit value for android:exported be defined when intent filters are present\]](https://stackoverflow.com/questions/73373944/flutter-targeting-s-version-31-and-above-requires-that-an-explicit-value-for) – Ivo Sep 08 '22 at 07:22

2 Answers2

34

Try adding this in AndroidManifest.xml. Inside <application> .... </application> tag.

   <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
              android:exported="true">   
    </receiver>

Update:

To explain the issue, from Android 12, for the application components such as Activity, BroadCast Receiver, Service.. one must explicitly add android:exported="" flag in Manifest Component. Source

This can be true or false.

If it is marked as true, other apps/system can start the particular component via Intent.

For example, for Launcher Activity we need to mark the activity as android:exported="true" . So that system launcher/ other launcher apps can start application by Intent calling the launcher activity.

In most cases, it wont be necessary to mark it as true.

In this case, adding exported = false also will work. So it is recommended to make it as false.

   <receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
              android:exported="false">   
    </receiver> 

Actually these changee for Android 12 flutter_local_notifications plugin as already added and fix is available on latest versions.

But when you add the package via flutter pub add flutter_local_notifications, it is only adding old version of the plugin. In my case it was downloading version 8.2.0 , but latest available version is 13.0.0 at the time of writing the answer. So when I explicitly made it to 13.0.0, this issue won't come.

The reason for flutter adding an older version might be the dependency of other packages.

So finally , to conclude, making flutter_local_notifications: ^13.0.0 explicitly in pubspec.yaml will solve this issue.

Gowtham K K
  • 3,123
  • 1
  • 11
  • 29
0

Add following lines in your android manifiest file

<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
          android:exported="true">   
</receiver>