Support for API Level 31 (Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported`)
See original GitHub issueBug Report
Problem
When I try to build my app using API level 31 and build tools 30.0.3 the build fails with an error, when I revert back to 30 build works fine.
What is expected to happen?
To build the app like what it is doing in previous builds.
What does actually happen?
Fail with Error:
#15 112.0 > Task :CordovaLib:parseReleaseLocalResources
#15 112.0 > Task :app:javaPreCompileRelease
#15 112.0 > Task :CordovaLib:writeReleaseAarMetadata
#15 112.3 > Task :app:desugarReleaseFileDependencies
#15 117.4
#15 117.4 > Task :app:processReleaseMainManifest FAILED
#15 117.4 /app/platforms/android/app/src/main/AndroidManifest.xml Error:
#15 117.4 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/mani
fest/activity-element#exported for details.
#15 117.4
#15 117.4 See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.
#15 117.4
#15 117.8
#15 117.8 > Task :app:mergeExtDexRelease
#15 117.9
#15 117.9 FAILURE: Build failed with an exception.
#15 117.9
#15 117.9 * What went wrong:
#15 117.9 Execution failed for task ':app:processReleaseMainManifest'.
#15 117.9 > 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.
#15 117.9
#15 117.9 * Try:
#15 117.9 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.
#15 117.9
#15 117.9 * Get more help at https://help.gradle.org
#15 117.9
#15 117.9 BUILD FAILED in 1m 11s
#15 117.9
#15 117.9 Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
#15 117.9
#15 117.9 You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
#15 117.9
#15 117.9 See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings
#15 117.9 22 actionable tasks: 22 executed
#15 118.2 Command failed with exit code 1: /app/platforms/android/gradlew :app:bundleRelease -b /app/platforms/android/build.gradle
#15 118.2 Error: Command failed with exit code 1: /app/platforms/android/gradlew :app:bundleRelease -b /app/platforms/android/build.gradle
#15 118.2 at makeError (/app/node_modules/execa/lib/error.js:60:11)
#15 118.2 at handlePromise (/app/node_modules/execa/index.js:118:26)
#15 118.2 at processTicksAndRejections (node:internal/process/task_queues:96:5)
#15 118.2 at async ProjectBuilder.build (/app/node_modules/cordova-android/lib/builders/ProjectBuilder.js:316:20)
#15 118.3 [ERROR] An error occurred while running subprocess cordova.
#15 118.3
#15 118.3 cordova build android --release --buildConfig build.json -d exited with exit code 1.
#15 118.3
#15 118.3 Re-running this command with the --verbose flag may provide more information.
Information
Command or Code
To save you some time, please see this repo https://github.com/capellasolutions/ionic-cordova-docker/tree/develop/example-app
Example App in develop branch is not working Please change https://github.com/capellasolutions/ionic-cordova-docker/blob/develop/example-app/app-builder.Dockerfile#L77 to 30.0.3
as 31.0.0
causes another issue in #1335.
Version information
Using cordova-android: 10.1.0
Ionic info:
Ionic:
Ionic CLI : 6.17.0 (/home/almothafar/.npm-global/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/angular 5.7.0
@angular-devkit/build-angular : 12.2.3
@angular-devkit/schematics : 12.2.3
@angular/cli : 12.2.3
@ionic/angular-toolkit : 4.0.0
Cordova:
Cordova CLI : 10.0.0
Cordova Platforms : not available
Cordova Plugins : not available
Utility:
cordova-res : not installed globally
native-run : not installed globally
System:
NodeJS : v16.4.1 (/usr/bin/node)
npm : 7.21.1
OS : Linux 5.10
Checklist
- I searched for existing GitHub issues
- I updated all Cordova tooling to most recent version
- I included all the necessary information above
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Targeting S+ (version 31 and above) requires that an explicit ...
Android 12 require you to add a piece of code to your main activity. Go to your project folder and open AndroidManifest.xml file....
Read more >Issues - GitHub
Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter ......
Read more >Behavior changes: Apps targeting Android 12
For apps that target Android 12 (API level 31) or higher, ... Android 12 and higher are required \ to specify an explicit...
Read more >"Apps targeting Android 12 and higher are required to specify ...
Hey, I try to create a android bundle, but i've this message : jar /opt/local/bin/manifestmergetool.jar --platform android --main ...
Read more >Error: Apps targeting Android 12 and higher are required to ...
Hello, I updated my project to target sdk version 31 but when I try to ... are required to specify an explicit value...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Problem arises due to SDK 31 with JDK 8 Upgrade to JDK11. Make sure to reses environment Variables and JAVA_HOME path
I’d confirm that you see
android:exported="true"
in your manifest, located atplatforms/android/app/src/main/AndroidManifest.xml
. If so, then your app should be configured properly and like was previously mentioned, the issue likely is within a third-party plugin.