Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
3 tasks done
almothafar opened this issue Sep 2, 2021 · 6 comments
Milestone

Comments

@almothafar
Copy link

almothafar commented Sep 2, 2021

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
@almothafar almothafar changed the title Support for API Level 31 Support for API Level 31 (Apps targeting Android 12 and higher are required to specify an explicit value for android:exported) Sep 2, 2021
@breautek breautek added this to the 11.0.0 milestone Sep 3, 2021
@erisu
Copy link
Member

erisu commented Oct 28, 2021

Resolved by #1372

@erisu erisu closed this as completed Oct 28, 2021
@alitalaee
Copy link

Would you help me to fix this issue? i have the same...
i want to build ionic android app for android 12 but give me error

@erisu
Copy link
Member

erisu commented Jun 24, 2022

@alitalaee this PR has already been merged and released in 10.1.2. You can see the Release Notes here.

  • If you are using an older version of the platform, I recommend upgrading.
  • If you already upgraded and still having this issue, it is possible that a plugin is adding stuff to the AndroidManifest file and not explicitly setting the flag. You will need to review which plugin it is coming from.

@alitalaee
Copy link

alitalaee commented Jun 24, 2022

@alitalaee this PR has already been merged and released in 10.1.2. You can see the Release Notes here.

  • If you are using an older version of the platform, I recommend upgrading.
  • If you already upgraded and still having this issue, it is possible that a plugin is adding stuff to the AndroidManifest file and not explicitly setting the flag. You will need to review which plugin it is coming from.

can you help me to fix that please???
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..
can i share my code with you to help me please?
ali.talaee.eng@gmail.com

@breautek
Copy link
Contributor

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.

@karanshahp121
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants