Ionic 4 Cordova - Run Android Firebase error all of a sudden

Thank you, this is working.

For everyone else:

Use @dpa99c1 fix! Just run

cordova plugin add https://github.com/dpa99c/cordova-plugin-firebase#GH-1057-April-05-android-build-issue

and build your app again.

4 Likes
Thank you, but I cannot add github  ( cordova plugin add https://github.com/dpa99c/cordova-plugin-firebase#GH-1057-April-05-android-build-issue).

package.json

{
“name”: “google_login”,
“version”: “0.0.1”,
“author”: “Ionic Framework”,
“homepage”: “http://ionicframework.com/”,
“private”: true,
“scripts”: {
“clean”: “ionic-app-scripts clean”,
“build”: “ionic-app-scripts build”,
“lint”: “ionic-app-scripts lint”,
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
},
“dependencies”: {
@angular/common”: “5.0.0”,
@angular/compiler”: “5.0.0”,
@angular/compiler-cli”: “5.0.0”,
@angular/core”: “5.0.0”,
@angular/forms”: “5.0.0”,
@angular/http”: “5.0.0”,
@angular/platform-browser”: “5.0.0”,
@angular/platform-browser-dynamic”: “5.0.0”,
@ionic-native/core”: “4.3.2”,
@ionic-native/firebase”: “^4.20.0”,
@ionic-native/google-plus”: “^4.20.0”,
@ionic-native/splash-screen”: “4.3.2”,
@ionic-native/status-bar”: “4.3.2”,
@ionic/storage”: “2.1.3”,
“cordova-android”: “7.1.4”,
“cordova-plugin-device”: “^1.1.4”,
“cordova-plugin-firebase”: “1.0.5”,
“cordova-plugin-googleplus”: “7.0.1”,
“cordova-plugin-ionic-webview”: “^1.2.1”,
“cordova-plugin-splashscreen”: “^4.0.3”,
“cordova-plugin-whitelist”: “^1.3.1”,
“ionic-angular”: “3.9.2”,
“ionic-plugin-keyboard”: “^2.2.1”,
“ionicons”: “3.0.0”,
“rxjs”: “5.5.2”,
“sw-toolbox”: “3.6.0”,
“zone.js”: “0.8.18”
},
“devDependencies”: {
@ionic/app-scripts”: “3.1.0”,
“typescript”: “2.4.2”
},
“description”: “An Ionic project”,
“cordova”: {
“plugins”: {
“cordova-plugin-googleplus”: {},
“ionic-plugin-keyboard”: {},
“cordova-plugin-whitelist”: {},
“cordova-plugin-device”: {},
“cordova-plugin-splashscreen”: {},
“cordova-plugin-ionic-webview”: {},
“cordova-plugin-firebase”: {}
},
“platforms”: [
“android”
]
}
}

when i run the code, i am getting this issue

Running command - failed!
[ERROR] An error occurred while running cordova build android (exit code 1):

    (truncated) ... le method found for setDefaults(Map<String,Object>,String)
                             FirebaseRemoteConfig.getInstance().setDefaults(defaultsToMap(defaults), namespace);
                                                               ^
         method FirebaseRemoteConfig.setDefaults(Map<String,Object>) is not applicable
           (actual and formal argument lists differ in length)
         method FirebaseRemoteConfig.setDefaults(int) is not applicable
           (actual and formal argument lists differ in length)
    D:\google_login\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:819: error:
    cannot find symbol
                             myTrace.incrementCounter(counterNamed);
                                    ^
       symbol:   method incrementCounter(String)
       location: variable myTrace of type Trace
    D:\google_login\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginInstanceIDService.java:17:
    error: method does not override or implement a method from a supertype
         @Override
         ^
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    7 errors
      FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.

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

    * Get more help at https://help.gradle.org

    BUILD FAILED in 28s
    27 actionable tasks: 12 executed, 15 up-to-date
    cmd: Command failed with exit code 1 Error output:
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    D:\google_login\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginInstanceIDService.java:6:
    error: cannot find symbol
    import com.google.firebase.iid.FirebaseInstanceIdService;
                                   ^
       symbol:   class FirebaseInstanceIdService
       location: package com.google.firebase.iid
    D:\google_login\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginInstanceIDService.java:8:
    error: cannot find symbol
    public class FirebasePluginInstanceIDService extends FirebaseInstanceIdService {
                                                          ^
       symbol: class FirebaseInstanceIdService
    D:\google_login\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:577: error:
    method getByteArray in class FirebaseRemoteConfig cannot be applied to given types;
                                 : FirebaseRemoteConfig.getInstance().getByteArray(key, namespace);
                                                                     ^
       required: String
       found: String,String
       reason: actual and formal argument lists differ in length
    D:\google_login\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:595: error:
    method getValue in class FirebaseRemoteConfig cannot be applied to given types;
                                 : FirebaseRemoteConfig.getInstance().getValue(key, namespace);
                                                                     ^
       required: String
       found: String,String
       reason: actual and formal argument lists differ in length
    D:\google_login\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:649: error:
    no suitable method found for setDefaults(Map<String,Object>,String)
                             FirebaseRemoteConfig.getInstance().setDefaults(defaultsToMap(defaults), namespace);
                                                               ^
         method FirebaseRemoteConfig.setDefaults(Map<String,Object>) is not applicable
           (actual and formal argument lists differ in length)
         method FirebaseRemoteConfig.setDefaults(int) is not applicable
           (actual and formal argument lists differ in length)
    D:\google_login\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:819: error:
    cannot find symbol
                             myTrace.incrementCounter(counterNamed);
                                    ^
       symbol:   method incrementCounter(String)
       location: variable myTrace of type Trace
    D:\google_login\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginInstanceIDService.java:17:
    error: method does not override or implement a method from a supertype
         @Override
         ^
    Note: Some input files use or override a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    7 errors

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':app:compileDebugJavaWithJavac'.
    > Compilation failed; see the compiler error output for details.

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

    * Get more help at https://help.gradle.org

    BUILD FAILED in 28s

Then wait for a official fix implementation…

1 Like

@dpa99c1 Solution worked for me.
Dont forget to run this command below
cordova platform rm android --nosave && cordova plugin add android --nosave

2 Likes

Solution is only for cordova-plugin-firebase
the error persists , in cordova-plugin-fcm

Ok. I confirm that the below changes make the app compile again, firebase realtime database access works and FCM push notifications are being sent and received:

  1. Delete the file MyFirebaseInstanceIDService.java in folder platforms\android\app\src\main\java\com\gae\scaffolder\plugin

  2. In case you use FCM, remove the last line from platforms\android\cordova-plugin-fcm-with-dependecy-updated<appname>-FCMPlugin.gradle
    ( // apply plugin: com.google.gms.googleservices.GoogleServicesPlugin )

  3. Rebuild

No other changes were done. Above #1 step was suggested by @mrHonest above, but he also had a step: 1 before that relating to adding @Ovverride before the “public void onNewToken(…” statement, but there was no such statement in the file on my installation…

2 Likes

Thanks a lot, it’s working

This seemed to work with FCM. I can build and send/receive messages. Thanks!

A wonderful person opened a pull request in the cordova-firebase-plugin official repo and it works.

Steps I did:

1 - Remove cordova-firebase-plugin with ionic cordova plugin remove cordova-firebase-plugin

2 - Install: ionic cordova plugin add https://github.com/dpa99c/cordova-plugin-firebase#GH-1057-April-05-android-build-issue

3 - rm -rf node_modules/ plugins/ platforms/android package-lock.json

4 - ionic cordova platform add android && npm install

5 - In my case I also use firebase js library in an old version becasue the newest ones are not working for me. With that library I always need to reinstall it manually after all the previous steps, so also I did: npm install firebase@4.12.1.

And now it’s working.

6 Likes

how do we fix this?
I only use Firebase for the analytics
on Ionic 3 and Android 6.4.
I tried updating project.properties to use 15+.
Removed Android and Added it back (this reset any project.properties values back) changed them back.
Did a build. got similar error.

This works for me :blue_heart:

Thanks!!! Works for me

Error: Failed to fetch plugin https://github.com/dpa99c/cordova-plugin-firebase#GH-1057-April-05-android-build-issue via registry.
Probably this is either a connection problem, or plugin spec is incorrect.

Indeed, as Colo9311 said, It seems refreshing node_modules is very important to get the fix work ! don’t be lazy guys, and go through deleting them all

I suddenly started having the same issue. No other changes to plugins, just basic javascript/typescript code changes. Could this be related somehow to the pending “Deprecated GCM”?

this worked! thank you so much!

thank you, this is working for me

When I try this solution, getting the below error.

Could not find com.google.firebase:firebase-messaging:17.5.0 .
Searched in the following locations:
file:/C:/Users/Admin/AppData/Local/Android/sdk/extras/m2repository/com/google/firebase/firebase-messaging/17.5.0 /firebase-messaging-17.5.0 .pom
file:/C:/Users/Admin/AppData/Local/Android/sdk/extras/m2repository/com/google/firebase/firebase-messaging/17.5.0 /firebase-messaging-17.5.0 .jar
file:/C:/Users/Admin/AppData/Local/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-messaging/17.5.0 /firebase-messaging-17.5.0 .pom
file:/C:/Users/Admin/AppData/Local/Android/sdk/extras/google/m2repository/com/google/firebase/firebase-messaging/17.5.0 /firebase-messaging-17.5.0 .jar

Thank you so much sir.
You saved my day.

sir i got below error:
>Probably this is either a connection problem, or plugin spec is incorrect.
**> **
> Check your connection and plugin name/version/URL.
**> **
> Error: npm: Command failed with exit code 1 Error output:
**> **
> npm ERR! code 128
**> **
> npm ERR! Command failed: git clone --depth=1 -q -b GH-1057-April-05-android-build-issue https://github.com/dpa99c/cordova-plugin-firebase.git /var/root/.npm/_cacache/tmp/git-clone-42b18bd4
**> **
> npm ERR! fatal: could not create leading directories of ‘/var/root/.npm/_cacache/tmp/git-clone-42b18bd4’: Permission denied
**> **
**> npm ERR! **
**> **
> npm ERR! A complete log of this run can be found in:
**> **
> npm ERR! /var/root/.npm/_logs/2019-05-08T05_53_24_361Z-debug.log
**> **
> [ ERROR ] An error occurred while running subprocess cordova .