'Gradle problem Android 12 Manifest Merger Failed

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

Here is my build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 31
    buildToolsVersion '30.0.3'
    defaultConfig {
        applicationId "com.lipova.taxi"
        minSdkVersion 21
        //noinspection OldTargetApi
        targetSdkVersion 31
        versionCode 1
        versionName "2.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
        useLibrary 'org.apache.http.legacy'
        manifestPlaceholders = [onesignal_app_id               : 'onesignal_app_id',
                                onesignal_google_project_number: 'REMOTE']
    }
    buildTypes {
        release {

            multiDexKeepFile file('multidex-config.txt')
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility '1.8'
        targetCompatibility '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    //noinspection GradleCompatible
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'com.google.firebase:firebase-database:20.0.4'
    implementation 'com.google.firebase:firebase-auth:21.0.3'
    implementation 'com.google.firebase:firebase-storage:20.0.1'
    implementation 'com.firebase:geofire-android:3.0.0'
    implementation 'com.google.android.gms:play-services-maps:18.0.2'
    implementation 'com.google.android.gms:play-services-places:17.0.0'
    implementation 'com.google.android.gms:play-services-location:19.0.1'
    implementation 'com.google.android.gms:play-services-gcm:17.0.0'
    implementation 'com.google.android.gms:play-services-auth:20.1.0'
    implementation 'com.facebook.android:facebook-login:8.1.0'

    implementation 'androidx.recyclerview:recyclerview:1.2.1'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.stripe:stripe-android:16.1.1'

    implementation 'com.github.bumptech.glide:glide:4.11.0'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.akexorcist:googledirectionlibrary:1.1.1'

    implementation 'com.onesignal:OneSignal:3.15.4'
    implementation 'com.google.android.libraries.places:places:2.6.0'

    implementation "com.github.addisonelliott:SegmentedButton:3.1.5"

    implementation 'com.paypal.sdk:paypal-android-sdk:2.16.0'
    implementation 'com.google.android.libraries.places:places:2.6.0'
    implementation 'com.github.rtchagas:pingplacepicker:1.1.2'

    implementation 'com.github.ybq:Android-SpinKit:1.4.0'


    implementation 'androidx.multidex:multidex:2.0.1'


    /* Needed for RxAndroid */
    implementation 'io.reactivex:rxandroid:1.2.1'
    implementation 'io.reactivex:rxjava:1.3.8'
    implementation 'io.reactivex.rxjava2:rxjava:2.2.10'


    /* Needed for Rx Bindings on views */
    implementation 'com.jakewharton.rxbinding:rxbinding:1.0.1'


    annotationProcessor 'com.jakewharton:butterknife:10.2.3'

    implementation 'com.squareup.retrofit2:retrofit:2.9.0' //Proguard
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0' //Proguard
    implementation 'com.squareup.retrofit2:converter-scalars:2.9.0' //Proguard

    /* Used for server calls */
    implementation 'com.squareup.okio:okio:2.9.0'
    implementation 'com.squareup.retrofit2:retrofit:2.9.0'

    /* Used to make Retrofit easier and GSON & Rx-compatible*/
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.squareup.retrofit2:adapter-rxjava:2.9.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

    /* Used to debug your Retrofit connections */
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'

    implementation "com.yuyakaido.android:card-stack-view:2.3.4"
    implementation 'com.lorentzos.swipecards:library:1.0.9'
    implementation 'com.mikhaellopez:circularprogressbar:3.0.3'
    implementation 'com.github.tintinscorpion:Dual-color-Polyline-Animation:1.0'

    implementation 'com.shreyaspatil:MaterialDialog:2.1'

    // Material Design Library
    implementation 'com.google.android.material:material:1.5.0'

    implementation 'com.ncorti:slidetoact:0.7.0'

    testImplementation 'junit:junit:4.13.2'
}

i already set...

    <activity
        android:name="com.lipova.taxi.Login.LauncherActivity"
        android:exported="true"
        android:screenOrientation="portrait">


Solution 1:[1]

As the targetSdkVersion =< 12, the <activity> in the AndroidManifest.xml must contain the parameter android:exported. This can be set to either true or false.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lars