首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ionic原生fcm插件问题

ionic原生fcm插件问题
EN

Stack Overflow用户
提问于 2017-07-02 15:33:42
回答 2查看 1K关注 0票数 0

我想在我的ionic 3应用程序中实现firebase推送通知。我已经添加了ionic natice fcm插件。但是当我使用以下命令构建应用程序时

代码语言:javascript
复制
ionic cordova build android

但它给了我一个错误,如下所示:

代码语言:javascript
复制
ionic cordova build android
Running app-scripts build: --iscordovaserve --externalIpRequired --nobrowser

[12:22:34]  build dev started ...
[12:22:34]  clean started ...
[12:22:34]  clean finished in 31 ms
[12:22:34]  copy started ...
[12:22:34]  transpile started ...
[12:22:52]  transpile finished in 17.82 s
[12:22:52]  preprocess started ...
[12:22:52]  deeplinks started ...
[12:22:52]  deeplinks finished in 250 ms
[12:22:52]  preprocess finished in 297 ms
[12:22:52]  webpack started ...
[12:22:55]  copy finished in 20.24 s
[12:23:15]  webpack finished in 22.49 s
[12:23:15]  sass started ...
[12:23:19]  sass finished in 4.08 s
[12:23:19]  postprocess started ...
[12:23:19]  postprocess finished in 32 ms
[12:23:19]  lint started ...
[12:23:19]  build dev finished in 44.83 s
> cordova build android
✖ Running command - failed!

[ERROR] Cordova encountered an error.
        You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova build android (exit code 1):

        (truncated) ... aLib:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
        :CordovaLib:compileDebugJavaWithJavac UP-TO-DATE
        :CordovaLib:processDebugJavaRes UP-TO-DATE
        :CordovaLib:transformResourcesWithMergeJavaResForDebug UP-TO-DATE
        :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForDebug UP-TO-DATE
        :CordovaLib:mergeDebugJniLibFolders UP-TO-DATE
        :CordovaLib:transformNative_libsWithMergeJniLibsForDebug UP-TO-DATE
        :CordovaLib:transformNative_libsWithSyncJniLibsForDebug UP-TO-DATE
        :CordovaLib:bundleDebug UP-TO-DATE
        :prepareAndroidCordovaLibUnspecifiedDebugLibrary UP-TO-DATE
        :preReleaseBuild UP-TO-DATE
        :CordovaLib:preReleaseBuild UP-TO-DATE
        :CordovaLib:checkReleaseManifest
        :CordovaLib:prepareReleaseDependencies
        :CordovaLib:compileReleaseAidl UP-TO-DATE
        :CordovaLib:compileReleaseNdk UP-TO-DATE
        :CordovaLib:copyReleaseLint UP-TO-DATE
        :CordovaLib:mergeReleaseShaders UP-TO-DATE
        :CordovaLib:compileReleaseShaders UP-TO-DATE
        :CordovaLib:generateReleaseAssets UP-TO-DATE
        :CordovaLib:mergeReleaseAssets UP-TO-DATE
        :CordovaLib:mergeReleaseProguardFiles UP-TO-DATE
        :CordovaLib:packageReleaseRenderscript UP-TO-DATE
        :CordovaLib:compileReleaseRenderscript UP-TO-DATE
        :CordovaLib:generateReleaseResValues UP-TO-DATE
        :CordovaLib:generateReleaseResources UP-TO-DATE
        :CordovaLib:packageReleaseResources UP-TO-DATE
        :CordovaLib:processReleaseManifest UP-TO-DATE
        :CordovaLib:generateReleaseBuildConfig UP-TO-DATE
        :CordovaLib:processReleaseResources UP-TO-DATE
        :CordovaLib:generateReleaseSources UP-TO-DATE
        :CordovaLib:incrementalReleaseJavaCompilationSafeguard UP-TO-DATE
        :CordovaLib:compileReleaseJavaWithJavac UP-TO-DATE
        :CordovaLib:processReleaseJavaRes UP-TO-DATE
        :CordovaLib:transformResourcesWithMergeJavaResForRelease UP-TO-DATE
        :CordovaLib:transformClassesAndResourcesWithSyncLibJarsForRelease UP-TO-DATE
        :CordovaLib:mergeReleaseJniLibFolders UP-TO-DATE
        :CordovaLib:transformNative_libsWithMergeJniLibsForRelease UP-TO-DATE
        :CordovaLib:transformNative_libsWithSyncJniLibsForRelease UP-TO-DATE
        :CordovaLib:bundleRelease UP-TO-DATE
        :prepareComAndroidSupportSupportCompat2600Alpha1Library UP-TO-DATE
        :prepareComAndroidSupportSupportCoreUi2600Alpha1Library UP-TO-DATE
        :prepareComAndroidSupportSupportCoreUtils2600Alpha1Library UP-TO-DATE
        :prepareComAndroidSupportSupportFragment2600Alpha1Library UP-TO-DATE
        :prepareComAndroidSupportSupportMediaCompat2600Alpha1Library UP-TO-DATE
        :prepareComAndroidSupportSupportV42600Alpha1Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesAds900Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesAdsLite900Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesBase900Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesBasement1102Library UP-TO-DATE
        :prepareComGoogleAndroidGmsPlayServicesTasks1102Library UP-TO-DATE
        :prepareComGoogleFirebaseFirebaseAnalytics1102Library UP-TO-DATE
        :prepareComGoogleFirebaseFirebaseAnalyticsImpl1102Library UP-TO-DATE
        :prepareComGoogleFirebaseFirebaseCommon1102Library UP-TO-DATE
        :prepareComGoogleFirebaseFirebaseCore1102Library UP-TO-DATE
        :prepareComGoogleFirebaseFirebaseIid1102Library UP-TO-DATE
        :prepareComGoogleFirebaseFirebaseMessaging1102Library UP-TO-DATE
        :prepareDebugDependencies
        :compileDebugAidl
        :compileDebugRenderscript
        :generateDebugBuildConfig UP-TO-DATE
        :generateDebugResValues UP-TO-DATE
        :processDebugGoogleServices
        Parsing json file: D:\Projects\Code\Other\DailySheet\DailySheetMobileApp\platforms\android\google-services.json
        :generateDebugResources
        :mergeDebugResources
        :processDebugManifest UP-TO-DATE
        :processDebugResources
        :generateDebugSources
        :incrementalDebugJavaCompilationSafeguard UP-TO-DATE
        :compileDebugJavaWithJavac UP-TO-DATE
        :compileDebugNdk UP-TO-DATE
        :compileDebugSources UP-TO-DATE
        :mergeDebugShaders UP-TO-DATE
        :compileDebugShaders
        :generateDebugAssets
        :mergeDebugAssets UP-TO-DATE
        :transformClassesWithDexForDebug FAILED

        BUILD FAILED

        Total time: 1 mins 48.75 secs

        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':transformClassesWithDexForDebug'.
        > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
        java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define
        Lcom/google/android/gms/internal/zzee;

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
        Error: cmd: Command failed with exit code 1 Error output:
        FAILURE: Build failed with an exception.

        * What went wrong:
        Execution failed for task ':transformClassesWithDexForDebug'.
        > com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
        java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define
        Lcom/google/android/gms/internal/zzee;

        * Try:
        Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

在我添加FCM插件之前,一切都很正常。我的项目信息如下:

代码语言:javascript
复制
global packages:

    @ionic/cli-utils : 1.4.0
    Cordova CLI      : 6.5.0
    Ionic CLI        : 3.4.0

local packages:

    @ionic/app-scripts              : 1.3.12
    @ionic/cli-plugin-cordova       : 1.4.0
    @ionic/cli-plugin-ionic-angular : 1.3.1
    Cordova Platforms               : android 6.1.2
    Ionic Framework                 : ionic-angular 3.5.0

System:

    Node       : v7.8.0
    OS         : Windows 10
    Xcode      : not installed
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 4.2.0

此外,我尝试删除所有插件和平台,并读取它。但是没有解决方案!:(

EN

回答 2

Stack Overflow用户

发布于 2018-05-07 04:07:47

此处提供的解决方案:https://forum.ionicframework.com/t/ionic-native-fcm-plugin-issue/96601/6

最终,我找到了解决方案,下面是我所做的:将android.gms:play-services-ads替换为firebase:firebase-ads:

build.gradle project.properties plugin.xml还会检查是否在android.gms:play-services-ads:X.X.X之后提供了任何版本,然后将其替换为android.gms

票数 1
EN

Stack Overflow用户

发布于 2018-07-07 18:08:01

在将Ionic原生FCM插件添加到您的应用程序之前,您需要在google firebase控制台上配置您的应用程序,并添加到应用程序根文件夹中的GoogleService-info.plist & google-services.json。

尝试删除插件,添加文件,然后重新添加插件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44868466

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档