0

I'm trying to run on my physical device a HelloWorld project which Android Studio creates when I click on a new project with empty activity, but when I run the project I received a Manifest merger failed only if compileSdkVersion is 31

The build.gradle(Module) contains:

android {
    compileSdkVersion 31
    buildToolsVersion "31.0.0"

    defaultConfig {
        applicationId "com.example.helloworld"
        minSdkVersion 16
        targetSdkVersion 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
}

So when I run the project I receive this 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.

The question is: Why this error doesn't appear when I use SdkVersion 29 in the build.gradle(Module), as follows?

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"

    defaultConfig {
        applicationId "com.example.helloworld"
        minSdkVersion 16
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
}

Finally, this creates doubt for me. If the new project is created automatically to compile with the latest SDK version that requires android:exported into Manifest why was it not inserted automatically?

Simone
  • 344
  • 2
  • 15

0 Answers0