Ionic build failed after installing facebook-connect plugin

Issue

I have an ionic 1 app that builds successfully for ios but fails for android.

If I remove the cordova-plugin-facebook-connect it builds successfully for android too so I assume the plugin is causing the failure.

Also, this problem only began after I upgraded the android-minSdkVersion from 19 to 28 – which Google Play demanded.

I have already installed both cordova-plugin-androidx and cordova-plugin-androidx-adapter.

Here is the message I get when I run ionic cordova run android.

Task :app:processDebugManifest FAILED
C:\Users\me\projects\myapp\platforms\android\app\src\main\AndroidManifest.xml:20:9-55 Error:
        Missing 'package' key attribute on element package at AndroidManifest.xml:20:9-55
C:\Users\me\projects\myapp\platforms\android\app\src\main\AndroidManifest.xml Error:
        Validation failed, exiting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs

* Try:
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.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

22 actionable tasks: 4 executed, 18 up-to-date
C:\Users\me\projects\myapp\platforms\android\gradlew: Command failed with exit code 1 Error output:
C:\Users\me\projects\myapp\platforms\android\app\src\main\AndroidManifest.xml:20:9-55 Error:
        Missing 'package' key attribute on element package at AndroidManifest.xml:20:9-55
C:\Users\me\projects\myapp\platforms\android\app\src\main\AndroidManifest.xml Error:
        Validation failed, exiting

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.

* Try:
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.

* Get more help at https://help.gradle.org

BUILD FAILED in 9s
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd build android --device exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

This is my ionic info:

Ionic:

   Ionic CLI         : 5.2.3 (C:\Users\me\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework   : ionic1 1.3.4
   @ionic/v1-toolkit : 3.2.15

Cordova:

   Cordova CLI       : not installed
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 10 other plugins)

Utility:

   cordova-res : 0.15.2
   native-run  : 0.2.8

System:

   NodeJS : v10.16.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.9.0
   OS     : Windows 10

And this is my plugin list:

> cordova.cmd plugin ls
cordova-plugin-add-swift-support 2.0.2 "AddSwiftSupport"
cordova-plugin-androidx 3.0.0 "cordova-plugin-androidx"
cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter"
cordova-plugin-device 2.0.2 "Device"
cordova-plugin-facebook-connect 3.1.0 "Facebook Connect"
cordova-plugin-globalization 1.11.0 "Globalization"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.2.1 "cordova-plugin-ionic-webview"
cordova-plugin-sign-in-with-apple 0.1.2 "cordova-plugin-sign-in-with-apple"
cordova-plugin-splashscreen 5.0.2 "Splashscreen"
cordova-plugin-statusbar 2.4.2 "StatusBar"
cordova-plugin-whitelist 1.3.5 "Whitelist"
cordova-signin-with-apple-plugin 0.1.1 "Signin With Apple"

Solution

You’re running into the issue described on https://android-developers.googleblog.com/2020/07/preparing-your-build-for-package-visibility-in-android-11.html. In https://github.com/cordova-plugin-facebook-connect/cordova-plugin-facebook-connect/issues/81, cordova-plugin-facebook-connect was updated to support Android 11 package visibility. That requires a more recent version of Gradle. If you update to cordova-android 9 or higher, that should fix this.

Answered By – Noah Cooper

Leave a Comment