【问题标题】:Ionic 5 : Can't use FCM Plugin : Google Firebase Cloud Messaging Cordova Push PluginIonic 5:无法使用 FCM 插件:Google Firebase Cloud Messaging Cordova Push Plugin
【发布时间】:2020-02-23 07:43:03
【问题描述】:

我一直在尝试为 Android 构建我的 Ionic 应用程序,但它总是以失败告终。我倒霉的原因是FCM插件:https://ionicframework.com/docs/native/fcm

→ Google Firebase Cloud Messaging Cordova Push Plugin https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated

这是我的 Ionic 配置:

Ionic:

   Ionic CLI                     : 5.4.16 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 5.0.0
   @angular-devkit/build-angular : 0.803.23
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.1.2

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0, ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.3, (and 15 other plugins)

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   Android SDK Tools : 26.1.1 (/Users/jonathan/Library/Android/sdk)
   ios-deploy        : 1.9.4
   ios-sim           : 8.0.2
   NodeJS            : v12.14.1 (/usr/local/bin/node)
   npm               : 6.13.4
   OS                : macOS Catalina
   Xcode             : Xcode 11.3.1 Build version 11C504

这是我的 Gradle 版本:

------------------------------------------------------------
Gradle 6.2
------------------------------------------------------------

Build time:   2020-02-17 08:32:01 UTC
Revision:     61d3320259a1a0d31519bf208eb13741679a742f

Kotlin:       1.3.61
Groovy:       2.5.8
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          13.0.2 (Oracle Corporation 13.0.2+8)
OS:           Mac OS X 10.15.3 x86_64

这是关于我的 Android Studio 的信息:

还有这个:

当我尝试在没有 FCM 插件的情况下构建我的 ionic 项目时,我没有任何错误,但是当我添加这个插件时,我得到了这个错误:

WARNING: Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'.
It will be removed at the end of 2018. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html
FCM PLUGIN GRADLE TOOLS VERSION: 3.5.0registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)

> Task :app:preBuild UP-TO-DATE
> Task :CordovaLib:preBuild UP-TO-DATE
> Task :CordovaLib:preDebugBuild UP-TO-DATE
> Task :CordovaLib:checkDebugManifest UP-TO-DATE
> Task :CordovaLib:processDebugManifest UP-TO-DATE

> Task :app:preDebugBuild FAILED
Dependency resolved to an incompatible version: Dependency(fromArtifactVersion=ArtifactVersion(groupId=com.google.android.gms, artifactId=play-services-clearcut, version=11.0.4), toArtifact=Artifact(groupId=com.google.android.gms, artifactId=play-services-tasks), toArtifactVersionString=[11.0.4])

FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[11.0.
  4]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.google.android.gms:play-services-clearcut:11.0.4 -> com.google.android.gms:play-services-tasks@[
  11.0.4], but play-services-tasks version was 16.0.1.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.android.gms:play-services-clearcut@11.0.4
  -- Project 'app' depends onto com.google.android.gms:play-services-safetynet@11.0.4
  -- Project 'app' depends onto com.google.firebase:firebase-analytics@16.5.0
  -- Project 'app' depends onto com.google.firebase:firebase-core@16.0.9
  -- Project 'app' depends onto com.google.android.gms:play-services-base@11.0.4
  -- Project 'app' depends onto com.google.firebase:firebase-messaging@18.0.0
  -- Project 'app' depends onto com.google.firebase:firebase-iid@18.0.0
  -- Project 'app' depends onto com.google.android.gms:play-services-ads@11.0.4
  -- Project 'app' depends onto com.google.android.gms:play-services-tasks@16.0.1
  -- Project 'app' depends onto com.google.android.gms:play-services-base@16.0.1
  -- Project 'app' depends onto com.google.firebase:firebase-common@17.0.0
  -- Project 'app' depends onto com.google.firebase:firebase-iid-interop@16.0.1
  -- Project 'app' depends onto com.google.android.gms:play-services-measurement-api@16.5.0

  For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
  endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
  github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
  uild.gradle file.

* 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 8s
3 actionable tasks: 1 executed, 2 up-to-date
Command finished with error code 1: /Users/jonathan/Desktop/projects/clients/findlover/platforms/android/gradlew cdvBuildDebug,-b,/Users/jonathan/Desktop/projects/clients/findlover/platforms/android/build.gradle
/Users/jonathan/Desktop/projects/clients/findlover/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[11.0.
  4]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.google.android.gms:play-services-clearcut:11.0.4 -> com.google.android.gms:play-services-tasks@[
  11.0.4], but play-services-tasks version was 16.0.1.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.android.gms:play-services-clearcut@11.0.4
  -- Project 'app' depends onto com.google.android.gms:play-services-safetynet@11.0.4
  -- Project 'app' depends onto com.google.firebase:firebase-analytics@16.5.0
  -- Project 'app' depends onto com.google.firebase:firebase-core@16.0.9
  -- Project 'app' depends onto com.google.android.gms:play-services-base@11.0.4
  -- Project 'app' depends onto com.google.firebase:firebase-messaging@18.0.0
  -- Project 'app' depends onto com.google.firebase:firebase-iid@18.0.0
  -- Project 'app' depends onto com.google.android.gms:play-services-ads@11.0.4
  -- Project 'app' depends onto com.google.android.gms:play-services-tasks@16.0.1
  -- Project 'app' depends onto com.google.android.gms:play-services-base@16.0.1
  -- Project 'app' depends onto com.google.firebase:firebase-common@17.0.0
  -- Project 'app' depends onto com.google.firebase:firebase-iid-interop@16.0.1
  -- Project 'app' depends onto com.google.android.gms:play-services-measurement-api@16.5.0

  For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
  endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
  github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
  uild.gradle file.

* 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 8s
Error: /Users/jonathan/Desktop/projects/clients/findlover/platforms/android/gradlew: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.

* What went wrong:
Failed to capture fingerprint of input files for task ':app:preDebugBuild' property 'compileManifests' during up-to-date check.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[11.0.
  4]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.google.android.gms:play-services-clearcut:11.0.4 -> com.google.android.gms:play-services-tasks@[
  11.0.4], but play-services-tasks version was 16.0.1.

  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.android.gms:play-services-clearcut@11.0.4
  -- Project 'app' depends onto com.google.android.gms:play-services-safetynet@11.0.4
  -- Project 'app' depends onto com.google.firebase:firebase-analytics@16.5.0
  -- Project 'app' depends onto com.google.firebase:firebase-core@16.0.9
  -- Project 'app' depends onto com.google.android.gms:play-services-base@11.0.4
  -- Project 'app' depends onto com.google.firebase:firebase-messaging@18.0.0
  -- Project 'app' depends onto com.google.firebase:firebase-iid@18.0.0
  -- Project 'app' depends onto com.google.android.gms:play-services-ads@11.0.4
  -- Project 'app' depends onto com.google.android.gms:play-services-tasks@16.0.1
  -- Project 'app' depends onto com.google.android.gms:play-services-base@16.0.1
  -- Project 'app' depends onto com.google.firebase:firebase-common@17.0.0
  -- Project 'app' depends onto com.google.firebase:firebase-iid-interop@16.0.1
  -- Project 'app' depends onto com.google.android.gms:play-services-measurement-api@16.5.0

  For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
  endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
  github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = false }" to your b
  uild.gradle file.

* 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 8s
    at ChildProcess.whenDone (/Users/jonathan/Desktop/projects/clients/findlover/node_modules/cordova-common/src/superspawn.js:135:23)
    at ChildProcess.emit (events.js:223:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Socket.<anonymous> (internal/child_process.js:430:11)
    at Socket.emit (events.js:223:5)
    at Pipe.<anonymous> (net.js:664:12)
[ERROR] An error occurred while running subprocess cordova.

        cordova build android --verbose exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.
  ionic:utils-process onBeforeExit handler: 'process.exit' received +0ms
  ionic:utils-process onBeforeExit handler: running 2 functions +0ms
  ionic:utils-process processExit: exiting (exit code: 1) +49ms

我在 youtube 上制作了一个关于此的视频:

https://youtu.be/sXod7xCDs8c

您可以在此视频中看到。我可以在没有 FCM 插件的情况下构建我的项目。 这个话题我已经查过了:after installing ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated my android built not working

我的问题不仅出在那台 Mac 上。我有其他 Mac 电脑,总是出现同样的错误。

我是 Android 的新手。我无法控制 Android 文件的配置。我的错误是什么原因?

【问题讨论】:

  • &lt;preference name="android-targetSdkVersion" value="27" /&gt; 。你的 targetSdkVersion 是什么?它在 config.xml 中

标签: ionic-framework cordova-plugin-fcm


【解决方案1】:

很遗憾,原始插件并未受到积极支持,并且取决于您的框架版本等,它可能会导致很多问题。

这个插件前一段时间有一个分支,这个分支版本有相当不错的支持和测试覆盖率:

https://github.com/andrehtissot/cordova-plugin-fcm-with-dependecy-updated#readme

我正在使用这个插件而不是原来的插件,到目前为止它运行良好。

【讨论】:

  • 我使用的是完全相同的插件:github.com/andrehtissot/…(在离子文档中 FCM 插件是“Google Firebase Cloud Messaging Cordova Push Plugin”)
  • 明白了,好的,我会检查我的项目以查看它依赖于 tmrw 的版本
【解决方案2】:

先安装以下插件 1 科尔多瓦插件添加科尔多瓦-插件-androidx 2 cordova插件添加cordova-plugin-androidx-adapter 现在从“cordova-plugin-fcm-with-dependecy-updated/ionic/ngx”导入 fcm 作为 import { FCM}; 删除平台并再次添加它们 然后再次构建项目

【讨论】:

    【解决方案3】:

    我使用firebasex 连接到 Firebase 并在那里执行包括 Firebase 云消息传递在内的操作。它适用于 iOS 和 Android,但我正在尝试查看 I can do away with using Google 是否。

    如果您使用 FCM,最终可能会使用 Firebase 提供的更多功能,包括 Crashalytics、AB 测试、存储和身份验证。所以你不妨使用提供完整 API 的东西。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-11
      • 2015-11-05
      • 2019-03-03
      • 1970-01-01
      • 2022-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多