离子本机fcm插件问题

时间:2017-07-02 07:33:42

标签: android ionic3 ionic-native cordova-plugin-fcm

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

ionic cordova build android

但它给我一个错误如下:

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插件之前,一切正常。我的项目信息如下:

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

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

2 个答案:

答案 0 :(得分:1)

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

  

最后,我找到了解决方案,这就是我所做的:替换   android.gms:play-services-ads with firebase:firebase-ads in below   文件:

     

build.gradle project.properties plugin.xml同时检查是否存在   版本是在android.gms:play-services-ads:X.X.X之后提供的   用android.gms替换它:play-services-ads:+

答案 1 :(得分:0)

在将Ionic本机FCM插件添加到您的应用之前,您需要在Google Firebase控制台上配置您的应用,并将其添加到您应用的根文件夹中的GoogleService-info.plist和google-services.json。

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

相关问题