Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

356
Visualizações
Android Studio error: "Manifest merger failed: Apps targeting Android 12"

I have updated my emulator version and Android SDK version to Android S (Android 12). After the update, I cannot run the project. I cannot run a Hello, World! project (empty project), but I can build Gradle as well as, but I can not run the project. I always got the error:

Manifest merger failed: 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.

How can I fix it?

Here is a screenshot:

This is a screenshot.

How can I solve this issue when using Android 12 SDK?

This question is about the issue after applying the solution to this, and is different than this question. Also, this question is older than this.

over 4 years ago · Hanz Gallego
10 Respostas
Responde à pergunta

0

You need to specify android:exported="false" or android:exported="true"

Manifest:

<activity
    android:name=".MainActivity"
    android:exported="true"
    android:theme="@style/Theme.MyApplication.NoActionBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

as mentioned in the document:

If your app targets Android 12 and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android: exported attribute for these app components.

Warning: If an activity, service, or broadcast receiver uses intent filters and doesn't have an explicitly-declared value for android:exported, your app can't be installed on a device that runs Android 12.

Also check when to use true/false for the 'android:exported' value.

over 4 years ago · Hanz Gallego Relatório

0

I had to also add android:exported="true" to all my receivers declared in the manifest. So I had something like this:

<receiver android:name=".alarms.AlarmReScheduler"
      android:exported="true">
      <intent-filter>
          <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />
          <action android:name="android.intent.action.BOOT_COMPLETED" />
          <action android:name="android.intent.action.QUICKBOOT_POWERON" />
          <action android:name="android.intent.action.PACKAGE_REPLACED" />
          <!-- For HTC devices -->
          <action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
      </intent-filter>
</receiver>

I don't think you should add android:exported="true" to just everything. You should only add that when those Broadcast receivers need to be visible to Android OS. The Intent filters in that code mean that I wanted Android OS to wake up my Android app and perform an operation.

android.intent.action.BOOT_COMPLETED is a very good example because Android OS sends broadcasts to every application installed in the device. So technically, it would mean that any Broadcast receiver that has an intent filter with actions should always declare android:exported="true".

over 4 years ago · Hanz Gallego Relatório

0

In your manifest, add android:exported="true" or android:exported="false " in your default launching activity attribute.

Done! You are all right to run your apps on Android 12.

<manifest ... >

    <activity
        android:name=".ui.dashboard.DashboardActivity"
        android:screenOrientation="portrait"
        android:exported="true"
        android:theme="@style/AppTheme.Launcher">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</manifest>

Set the android:exported value according to your requirement.

Whether the broadcast receiver can receive messages from non-system sources outside its application — "true" if it can, and "false" if not. If "false", the only messages the broadcast receiver can receive are those sent by the system, components of the same application, or applications with the same user ID.

If unspecified, the default value depends on whether the broadcast receiver contains intent filters. If the receiver contains at least one intent filter, then the default value is "true". Otherwise, the default value is "false".

This attribute is not the only way to limit a broadcast receiver's external exposure. You can also use permission to limit the external entities that can send messages (see the permission attribute).

From Android Documentation

over 4 years ago · Hanz Gallego Relatório

0

Your question may have flagged for duplication because of this post: Manifest merger failed targeting Android 12, although yours was posted a week earlier. I don't see the flag now.

To clarify another answer, note that android:exported should be set true for your main activity, or it won't launch despite an encouraging 'Launch succeeded' message from Android Studio as no other app, or even the Android system itself, can launch it.

<activity
    android:name=".MainActivity"
    android:exported="true"

For other activities with intents buried in your merged manifests, this would normally be set to false.

over 4 years ago · Hanz Gallego Relatório

0

This will help for 2021 users.

In one of your two build.gradle files you should be able to find the line targetSDK 31. Change that to 30 and then do a gradle sync (a small bar will appear above the main code window where you can click "Sync now") and you should be good to go.

over 4 years ago · Hanz Gallego Relatório

0

Enter image description here

In your launcher activity, declare "android: exported":

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

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

</activity>

If true “android: exported= true” it means the activity is accessible to any app and can be launched by its exact class name.

If false “android: exported = false” it means the activity can be launched only by the components of the same application with the same user ID, or privileged system components.

For more details check here.

over 4 years ago · Hanz Gallego Relatório

0

I ran into the same issue after targeting Android 12 in my project.

The problem was the project was quite big, with multiple AndroidManifest.xml files, and android:exported missing in many places.

I ended up creating a Gradle task to fill the missing android:exported attributes automatically for me.

Here is the link.

over 4 years ago · Hanz Gallego Relatório

0

I was getting this error even when I added android:exported="true" in all activities, receivers etc. The thing that worked for me was to change compileSdkVersion and targetSdkVersion to 30.

over 4 years ago · Hanz Gallego Relatório

0

Update version of androidTestImplementation 'androidx.test.ext:junit:1.1.1' to latest version like: - androidTestImplementation 'androidx.test.ext:junit:1.1.3' from build.gradle app level.

over 4 years ago · Hanz Gallego Relatório

0

For apps targeting Android 12

Change your app's targetSdkVersion to S(32 Or 31) to enable the new behavior.

Then Specify android:exorted="" attribute in Manifest either true or false depends on Activity

For Laucher Activity Such As Splash or MainActivity Use android:exported="true" and for the rest Activities use android:exported="false"

E.g:

    //it's **true** for laucher Activity
    <activity android:name=".SplashActivity"
              android:exported="true" />

     //it's **false** for rest Activities
     <activity android:name=".MainActivity"
              android:exported="false" />
over 4 years ago · Hanz Gallego Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda