安装 facebook-connect 插件后离子构建失败

Ionic build failed after installing facebook-connect plugin

我有一个 ionic 1 应用程序,它为 ios 构建成功,但为 android 构建失败。

如果我删除 cordova-plugin-facebook-connect 它也会为 android 成功构建,所以我假设插件导致失败。

此外,这个问题是在我将 android-minSdkVersion 从 19 升级到 28 之后才出现的 - Google Play 要求。

我已经安装了 cordova-plugin-androidxcordova-plugin-androidx-adapter

这是我在 运行 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.

这是我的 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

这是我的插件列表:

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

您 运行 遇到了 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 已更新以支持 Android 11 包可见性。这需要更新版本的 Gradle。如果您更新到 cordova-android 9 或更高版本,应该可以解决此问题。