question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for API Level 31 (Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported`)

See original GitHub issue

Bug 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:closed
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
karanshahp121commented, Nov 25, 2022

Problem arises due to SDK 31 with JDK 8 Upgrade to JDK11. Make sure to reses environment Variables and JAVA_HOME path

0reactions
breautekcommented, Jun 24, 2022

i did upgrade to latest platform but it does not work and of course added android:exported=“true” in all activity section on Manifest file but give me error…

I’d confirm that you see android:exported="true" in your manifest, located at platforms/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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found