5

I've updated my SDK version to 31, afterward I get this error. this is my Gradle :

    android {
    compileSdkVersion 31

    defaultConfig {
        applicationId "com.persiandesigners.alldentshops"
        minSdkVersion 16
        targetSdkVersion 31
        vectorDrawables.useSupportLibrary = true
        versionCode 1
        versionName "1"
    }

    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

dependencies {
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha01'
    implementation 'androidx.cardview:cardview:1.0.0-alpha01'
    implementation 'com.google.android.material:material:1.2.0-alpha01'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta4'

I get this error : Manifest merger failed : android:exported needs to be explicitly specified for . 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.

I did what it says, this is my manifest code :

<activity
        android:name="mypackage.MainActivity"
        android:exported="true"
        tools:node="merge"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/SplashScreenTheme"
        android:windowSoftInputMode="stateAlwaysHidden">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

this is the launcher activity and I've added android:exported tag , I tried clean and rebuilt but It didn't work . I still gets mergin error in manifest merge :

Merging Errors: 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. forushgah_alldentalshop.app main manifest (this file)

it's pointed to the MainActivity activity

Navid Abutorab
  • 1,667
  • 7
  • 31
  • 58
  • Try [this](https://stackoverflow.com/questions/68554294/androidexported-needs-to-be-explicitly-specified-for-activity-apps-targeting) https://stackoverflow.com/questions/68554294/androidexported-needs-to-be-explicitly-specified-for-activity-apps-targeting – Ahmed Karam Nov 29 '21 at 07:44

2 Answers2

3

if you are using flutter ,may some deprecated lib in your app is causing this.. in my case: upgrading flutter_local_notifications to the latest version (now is 9.3.2) solved this error..

Amer Alzibak
  • 1,489
  • 15
  • 16
2

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

Please note this is applicable to all the activities, services, broadcast receivers that use an intent-filter.

Make the changes. Save it. Invalidate cache and restart android studio and check.

  • What if in my project theses errors happen but related to activity/services from AAR libraries? What can I do to solve it? I can't even modify theses files. – emanoellucas Dec 20 '22 at 22:11