1
resposta

Erro ao emular o app

Estou tentando fazer um aplicativo.

E estou com o seguinte erro na hora de emular:

Launching lib\main.dart on sdk gphone64 x86 64 in debug mode... Running Gradle task 'assembleDebug'... D:\Desktop\wagua\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.

  • Get more help at https://help.gradle.org

BUILD FAILED in 19s Exception: Gradle task assembleDebug failed with exit code 1

No código, não aparecem erros.

Podem me ajudar?

1 resposta

Olá, Arthur!

Parece que você está enfrentando um problema comum que ocorre ao tentar emular um aplicativo que usa o Flutter em um dispositivo Android 12 ou superior. Isso ocorre porque, a partir do Android 12, é necessário especificar explicitamente o atributo android:exported para qualquer componente do aplicativo que tenha um filtro de intenção definido.

No seu caso, o erro está relacionado ao componente ScheduledNotificationBootReceiver do pacote flutterlocalnotifications.

Para resolver esse problema, você precisa adicionar o atributo android:exported ao componente relevante no arquivo AndroidManifest.xml. Aqui está um exemplo de como você pode fazer isso:

<receiver android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
        <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
    </intent-filter>
</receiver>

Neste exemplo, eu adicionei android:exported="true" à definição do receptor. O valor "true" ou "false" que você deve usar depende de se você deseja permitir que outros aplicativos além do seu iniciem este componente ou não.

Por favor, tente fazer essa alteração e veja se resolve o problema.

Espero ter ajudado e bons estudos!