andrehtissot / cordova-plugin-fcm-with-dependecy-updated

Google FCM Push Notifications Cordova Plugin
MIT License
210 stars 273 forks source link

Adding to existing Ionic project - Could not create task ':app:processDebugGoogleServices' #246

Open code-by opened 3 years ago

code-by commented 3 years ago

I already have Ionic project that works on Android/iOS and need to add Push Notifications there.

some dependencies from package.json:

    "@ionic-native/core": "^5.18.0",
    "@ionic/angular": "^4.11.7",
    "caniuse-lite": "^1.0.30001016",
    "cordova-android": "^8.1.0",
    "cordova-browser": "^6.0.0",
    "cordova-ios": "^5.1.1",
    "firebase": "^7.24.0",
    "ionic-native": "^2.9.0",
...
  "cordova": {
    "plugins": {
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "cordova-plugin-camera": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-file": {},
      "cordova-custom-config": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-statusbar": {},
      "cordova-plugin-console": {},
      "cordova-plugin-fcm-with-dependecy-updated": {
        "ANDROID_DEFAULT_NOTIFICATION_ICON": "@mipmap/ic_launcher",
        "ANDROID_FCM_VERSION": "21.0.0",
        "ANDROID_FIREBASE_BOM_VERSION": "26.0.0",
        "ANDROID_GOOGLE_SERVICES_VERSION": "4.3.4",
        "ANDROID_GRADLE_TOOLS_VERSION": "4.1.0"
      }
    },

ionic info:

Ionic:
   Ionic CLI                     : 6.12.4 (/home/user/.nvm/versions/node/v10.18.0/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 4.11.7
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.1.1
Cordova:
   Cordova CLI       : 10.0.0
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-webview 4.1.3, (and 9 other plugins)
Utility:
   cordova-res : not installed
   native-run  : 1.3.0

Android project.properties:

target=android-28
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.android.support:support-v4:27.+
cordova.system.library.2=com.android.support:support-annotations:27.+
cordova.gradle.include.1=cordova-plugin-fcm-with-dependecy-updated/projectname-FCMPlugin.gradle

\app\buid.gradle:

apply plugin: 'com.android.application'

buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
    }
}
allprojects {
    repositories {
        mavenCentral()
        jcenter()
    }
}
task wrapper(type: Wrapper) {
    gradleVersion = '4.10.3'
}

ProjectBuilder.js:

var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.10.3-all.zip';

In Firebase console I have added Android project and donwload google-services.json to project root, then

ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated

now I have:

> cordova build android --device
[cordova] 
[cordova] FAILURE: Build failed with an exception.
[cordova] 
[cordova] * What went wrong:
[cordova] A problem occurred configuring project ':app'.
[cordova] > Could not create task ':app:processDebugGoogleServices'.
[cordova]    > Cannot create a proxy class for abstract class 'GoogleServicesTask'.
...

any help/suggestions would be appreciated!

5h4k4r commented 3 years ago

Go to your config.xml file and check to see if your app id is the same as your android project app id in your firebase application you created before!

if your app id in config.xml is for example: e.example.com, then the android app id in your firebase project must be the same, otherwise you'll get this error!

abdullahbhojani commented 3 years ago

I already have Ionic project that works on Android/iOS and need to add Push Notifications there.

some dependencies from package.json:

    "@ionic-native/core": "^5.18.0",
    "@ionic/angular": "^4.11.7",
    "caniuse-lite": "^1.0.30001016",
    "cordova-android": "^8.1.0",
    "cordova-browser": "^6.0.0",
    "cordova-ios": "^5.1.1",
    "firebase": "^7.24.0",
    "ionic-native": "^2.9.0",
...
  "cordova": {
    "plugins": {
      "cordova-plugin-geolocation": {
        "GEOLOCATION_USAGE_DESCRIPTION": "To locate you"
      },
      "cordova-plugin-camera": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-file": {},
      "cordova-custom-config": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-statusbar": {},
      "cordova-plugin-console": {},
      "cordova-plugin-fcm-with-dependecy-updated": {
        "ANDROID_DEFAULT_NOTIFICATION_ICON": "@mipmap/ic_launcher",
        "ANDROID_FCM_VERSION": "21.0.0",
        "ANDROID_FIREBASE_BOM_VERSION": "26.0.0",
        "ANDROID_GOOGLE_SERVICES_VERSION": "4.3.4",
        "ANDROID_GRADLE_TOOLS_VERSION": "4.1.0"
      }
    },

ionic info:

Ionic:
   Ionic CLI                     : 6.12.4 (/home/user/.nvm/versions/node/v10.18.0/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 4.11.7
   @angular-devkit/build-angular : 0.801.3
   @angular-devkit/schematics    : 8.1.3
   @angular/cli                  : 8.1.3
   @ionic/angular-toolkit        : 2.1.1
Cordova:
   Cordova CLI       : 10.0.0
   Cordova Platforms : android 8.1.0
   Cordova Plugins   : cordova-plugin-ionic-webview 4.1.3, (and 9 other plugins)
Utility:
   cordova-res : not installed
   native-run  : 1.3.0

Android project.properties:

target=android-28
android.library.reference.1=CordovaLib
android.library.reference.2=app
cordova.system.library.1=com.android.support:support-v4:27.+
cordova.system.library.2=com.android.support:support-annotations:27.+
cordova.gradle.include.1=cordova-plugin-fcm-with-dependecy-updated/projectname-FCMPlugin.gradle

\app\buid.gradle:

apply plugin: 'com.android.application'

buildscript {
    repositories {
        mavenCentral()
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.3.0'
    }
}
allprojects {
    repositories {
        mavenCentral()
        jcenter()
    }
}
task wrapper(type: Wrapper) {
    gradleVersion = '4.10.3'
}

ProjectBuilder.js:

var distributionUrl = process.env['CORDOVA_ANDROID_GRADLE_DISTRIBUTION_URL'] || 'https\\://services.gradle.org/distributions/gradle-4.10.3-all.zip';

In Firebase console I have added Android project and donwload google-services.json to project root, then

ionic cordova plugin add cordova-plugin-fcm-with-dependecy-updated

now I have:

> cordova build android --device
[cordova] 
[cordova] FAILURE: Build failed with an exception.
[cordova] 
[cordova] * What went wrong:
[cordova] A problem occurred configuring project ':app'.
[cordova] > Could not create task ':app:processDebugGoogleServices'.
[cordova]    > Cannot create a proxy class for abstract class 'GoogleServicesTask'.
...

any help/suggestions would be appreciated!

has anyone solved this issue?