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

Same here, and also with no code changes since last build.
Just done a “ionic cordova resources” to upload the final version to stores and now I can’t compile :frowning:

Ionic:

   ionic (Ionic CLI)  : 4.12.0 (/usr/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.8.0
   @ionic/app-scripts : 3.0.0

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.0.0, ios 4.5.5
   Cordova Plugins       : no whitelisted plugins (11 plugins total)

System:

   Android SDK Tools : 26.1.1 (/opt/android-sdk/)
   NodeJS            : v8.15.1 (/usr/bin/node)
   npm               : 6.4.1
   OS                : Linux 4.4

cordova firebase 1.0.5

Please try my PR

Same problem here

ref this
then solution:

step:1
add @Override in MyFirebaseMessagingService in the path
…\platforms\android\src\com\gae\scaffolder\plugin\MyFirebaseMessagingService.java

    @Override
    public void onNewToken(String s) {
        super.onNewToken(s);
        Log.d("NEW_TOKEN",s);
    }

step2:
delete file MyFirebaseInstanceIDService.java
in the path
…\platforms\android\src\com\gae\scaffolder\plugin\MyFirebaseInstanceIDService.java

step:3
build again.

this works to me

11 Likes

I’m dealing with simmilar issue, only running Ionic 3:
cannot find symbol import com.google.firebase.iid.FirebaseInstanceIdService;

Error appeared out of nowhere. Yesterday I was able to build my project, today I cannot.

thanks!
it works to me :slight_smile:

@stkzcsqe

Which solution you used? Are you using FCM or Firebase?

If i try that it get the same error as the topic owner.

\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

Does not work. In my ionic project is no file “MyFirebaseMessagingService.java”

I am using the cordova-plugin-firebase plugin.

User fjckls on github posted a solution that allowed me to build, at least for now it’s an effective patch: https://github.com/arnesson/cordova-plugin-firebase/issues/1057#issuecomment-490000068

This is due to the firebase updates on April 05. Here https://firebase.google.com/support/release-notes/android#update_-_april_02_2019, I found the last working versions and adjusted my project.properties accordingly like so

cordova.system.library.4=com.google.firebase:firebase-core:16.0.8 cordova.system.library.5=com.google.firebase:firebase-messaging:17.5.0 cordova.system.library.6=com.google.firebase:firebase-config:16.4.1 cordova.system.library.7=com.google.firebase:firebase-perf:16.2.4

Here all dependencies are locked to the specific version (Update - April 02, 2019) instead of +, which would get you the latest version thus breaking the build process.

Now I can build successfully! Hope it helps!

project.properties can be found on platforms/android/project.properties

14 Likes

This is not working for me. I have changed the project.properties and when running

ionic cordova run android

I am still getting these errors:

D:\ionic\switch_ionic4\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:\ionic\switch_ionic4\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:\ionic\switch_ionic4\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:610: 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:\ionic\switch_ionic4\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:629: 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:\ionic\switch_ionic4\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:686: 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:\ionic\switch_ionic4\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePlugin.java:885: error: cannot find symbol
                        myTrace.incrementCounter(counterNamed);
                               ^
  symbol:   method incrementCounter(String)
  location: variable myTrace of type Trace
D:\ionic\switch_ionic4\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.
Note: D:\ionic\switch_ionic4\platforms\android\app\src\main\java\nl\xservices\plugins\SocialSharing.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
7 errors
:app:compileDebugJavaWithJavac 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.

my package.json looks like this:

{
  "name": "switch_ionic4",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^7.2.2",
    "@angular/core": "^7.2.2",
    "@angular/forms": "^7.2.2",
    "@angular/http": "^7.2.2",
    "@angular/platform-browser": "^7.2.2",
    "@angular/platform-browser-dynamic": "^7.2.2",
    "@angular/router": "^7.2.2",
    "@ionic-native/app-version": "^5.2.0",
    "@ionic-native/badge": "^5.2.0",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/firebase": "^5.2.0",
    "@ionic-native/in-app-browser": "^5.2.0",
    "@ionic-native/launch-navigator": "^5.4.0",
    "@ionic-native/social-sharing": "^5.2.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^4.1.2",
    "@ionic/core": "^4.1.2",
    "@ionic/storage": "^2.2.0",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "angular2-moment": "^1.9.0",
    "chart.js": "^2.7.3",
    "chartjs-plugin-labels": "^1.1.0",
    "cordova-android": "7.1.4",
    "cordova-ios": "4.5.5",
    "cordova-plugin-actionsheet": "^2.3.3",
    "cordova-plugin-app-version": "0.1.9",
    "cordova-plugin-badge": "0.8.8",
    "cordova-plugin-device": "2.0.2",
    "cordova-plugin-dialogs": "^2.0.1",
    "cordova-plugin-firebase": "2.0.5",
    "cordova-plugin-inappbrowser": "3.0.0",
    "cordova-plugin-ionic-keyboard": "^2.0.5",
    "cordova-plugin-ionic-webview": "^3.0.0",
    "cordova-plugin-splashscreen": "5.0.2",
    "cordova-plugin-statusbar": "2.4.2",
    "cordova-plugin-whitelist": "1.3.3",
    "cordova-plugin-x-socialsharing": "5.4.4",
    "cordova-sqlite-storage": "3.2.0",
    "core-js": "^2.5.4",
    "es6-promise-plugin": "^4.2.2",
    "g": "^2.0.1",
    "ionic": "^4.12.0",
    "moment": "^2.24.0",
    "rxjs": "~6.3.3",
    "uk.co.workingedge.phonegap.plugin.launchnavigator": "5.0.4",
    "zone.js": "~0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.12.3",
    "@angular-devkit/build-angular": "^0.13.8",
    "@angular-devkit/core": "~7.2.3",
    "@angular-devkit/schematics": "~7.2.3",
    "@angular/cli": "~7.3.1",
    "@angular/compiler": "~7.2.2",
    "@angular/compiler-cli": "~7.2.2",
    "@angular/language-service": "~7.2.2",
    "@ionic/angular-toolkit": "~1.4.0",
    "@ionic/lab": "1.0.24",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~10.12.0",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.4",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~8.0.0",
    "tslint": "~5.12.0",
    "typescript": "~3.1.6"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-sqlite-storage": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-app-version": {},
      "cordova-plugin-x-socialsharing": {
        "ANDROID_SUPPORT_V4_VERSION": "24.1.1+"
      },
      "uk.co.workingedge.phonegap.plugin.launchnavigator": {
        "GOOGLE_API_KEY_FOR_ANDROID": "{your_api_key}",
        "OKHTTP_VERSION": "3.+",
        "LOCATION_USAGE_DESCRIPTION": "This app requires access to your location for navigation purposes"
      },
      "cordova-plugin-firebase": {
        "IOS_HIDE_FOREGROUND_NOTIFICATION": "true"
      },
      "cordova-plugin-badge": {},
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {}
    },
    "platforms": [
      "ios",
      "android"
    ]
  }
}
1 Like

Same problem here. Tested the project.properties suggested patch.
Unsuccessfull

As like for many others, the problem for me started today

Thanks! this worked for me!

1 Like

Hello same issue here on Ionic 3 and cordova-plugin-firebase 1.0.5.
My Ionic info:

cli packages: (/usr/local/lib/node_modules)

@ionic/cli-utils  : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:

cordova (Cordova CLI) : 8.0.0

local packages:

@ionic/app-scripts : 3.2.0
Cordova Platforms  : android 7.0.0 browser 5.0.3 ios 4.5.5
Ionic Framework    : ionic-angular 3.9.2

System:

Android SDK Tools : 26.1.1
Node              : v8.11.4
npm               : 5.6.0
OS                : macOS High Sierra
Xcode             : Xcode 10.1 Build version 10B61

Environment Variables:

ANDROID_HOME : /Users/Zento/Library/Android/sdk

I suddenly have the same issue this morning:

FirebasePluginInstanceIDService.java:6: error:
cannot find symbol import com.google.firebase.iid.FirebaseInstanceIdService;

I’m trying the fix of mrHonest
but I do not have those paths in my application:

\platforms\android\src\com\gae\scaffolder\plugin\MyFirebaseMessagingService.java
\platforms\android\src\com\gae\scaffolder\plugin\MyFirebaseInstanceIDService.java

What I have though is:

/platforms/android/app/src/main/java/org/apache/cordova/firebase/FirebasePluginMessagingService.java
/platforms/android/app/src/main/java/org/apache/cordova/firebase/FirebasePluginInstanceIDService.java

Or:

/plugins/cordova-plugin-firebase/src/android/FirebasePluginMessagingService.java
/plugins/cordova-plugin-firebase/src/android/FirebasePluginInstanceIDService.java

In FirebasePluginMessagingService.java there is no “onNewToken” methods. So I cannot only add “@Override” to it.

However I tried editing the file by adding to it the entire method like that:

//at /platforms/android/app/src/main/java/org/apache/cordova/firebase/FirebasePluginMessagingService.java

public class FirebasePluginMessagingService extends FirebaseMessagingService {

    private static final String TAG = "FirebasePlugin";

    /**
    * Fix from https://forum.ionicframework.com/t/ionic-4-cordova-run-android-firebase-error-all-of-a-sudden/163204/23
     */
    @Override
    public void onNewToken(String s) {
        super.onNewToken(s);
        Log.d("NEW_TOKEN",s);
    }
    /** END FIX */

    /**
     * Get a string from resources without importing the .R package
     *
     * @param name Resource Name
     * @return Resource
     */
    private String getStringResource(String name) {
        return this.getString(
                this.getResources().getIdentifier(
                        name, "string", this.getPackageName()
                )
        );
    }

// ...

}

After that I had renamed /platforms/android/app/src/main/java/org/apache/cordova/firebase/FirebasePluginInstanceIDService.java to /platforms/android/app/src/main/java/org/apache/cordova/firebase/FirebasePluginInstanceIDService.java**.old**

When I restart the build, original error is gone but followings appears:


:app:compileDebugJavaWithJavac
/Users/zento/Projets/dev/carrefour-spectacles-with-node/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
/Users/zento/Projets/dev/carrefour-spectacles-with-node/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
/Users/zento/Projets/dev/carrefour-spectacles-with-node/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)
/Users/zento/Projets/dev/carrefour-spectacles-with-node/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
Note: Some input files use or override a deprecated API.

Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
4 errors

FAILED

FAILURE: Build failed with an exception.

I will give a try to systems_qualigy’s patch…

Errors started today.

I’ve just managed to build with the solution of changing project.properties
Firstly I’ve blindly copied everything and tested and it did’nt work. Then I realised that my corodva.system.library.XX didn’t match exactly those from the the patch

When I adjusted to make the match, the build executed perfectly

Hope this may help someone!
Thank you guys

1 Like

Where did you find the right Cordova.system.lybrary.XX settings? I can’t find anything about that

I’ve created a PR to fix this: https://github.com/arnesson/cordova-plugin-firebase/pull/1058

8 Likes

apparently it’s because google deprecated FirebaseInstanceService, now you must use FirebaseMessagingService

1 Like

All this errors are caused by installing:
cordova-plugin-fcm-with-dependecy-updated

remove this plugin:

cordova plugin remove cordova-plugin-fcm-with-dependecy-updated

and you will be able to build your project again…but FCM won’t work obviously :slight_smile:

Hi, i am working in Ionic 3 and cordova-plugin-firebase , i am facing following issue

The library com.google.android.gms:play-services-measurement-base is being reque
sted by various other libraries at [[16.5.0,16.5.0], [16.4.0,16.4.0]], but resol
ves to 16.5.0. Disable the plugin and check your dependencies tree using ./gradl
ew :app:dependencies.

1 Like

Yes. I am also facing same problem