Cordova-plugin-firebasex: Android build error

Created on 8 Apr 2020  ·  5Comments  ·  Source: dpa99c/cordova-plugin-firebasex

Bug report

Current behavior:


Building on android throws compilation error that result in a failed build.


After reverting from 9.0.1 back to 8.0.1 the build is OK again.

Environment information

  • Cordova CLI version
  • Cordova platform version

    • Installed platforms: android 8.1.0

  • Plugins & versions installed in project (including this plugin)

    • cordova-custom-config 5.1.0 "cordova-custom-config" cordova-plugin-actionsheet 2.3.3 "ActionSheet" cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx" cordova-plugin-androidx-adapter 1.1.0 "cordova-plugin-androidx-adapter" cordova-plugin-app-update 2.0.2 "AppUpdate" cordova-plugin-appversion 1.0.0 "App Version" cordova-plugin-camera 4.1.0 "Camera" cordova-plugin-device 2.0.3 "Device" cordova-plugin-dialogs 2.0.2 "Notification" cordova-plugin-email-composer 0.9.2 "EmailComposer" cordova-plugin-file 6.0.2 "File" cordova-plugin-file-opener2 2.2.1 "File Opener2" cordova-plugin-firebasex 9.0.1 "Google Firebase Plugin" cordova-plugin-geolocation 4.0.2 "Geolocation" cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 4.1.3 "cordova-plugin-ionic-webview" cordova-plugin-ios-disableshaketoedit 1.0.0 "iOS Disable Shake to Edit" cordova-plugin-network-information 2.0.2 "Network Information" cordova-plugin-screen-orientation 3.0.2 "Screen Orientation" cordova-plugin-splashscreen 5.0.3 "Splashscreen" cordova-plugin-statusbar 2.4.3 "StatusBar" cordova-plugin-whitelist 1.3.4 "Whitelist" cordova-sqlite-storage 3.4.1 "Cordova sqlite storage plugin - cordova-sqlite-storage plugin version" es6-promise-plugin 4.2.2 "Promise" uk.co.workingedge.phonegap.plugin.launchnavigator 5.0.4 "Launch Navigator"

  • Dev machine OS and version, e.g.

    • Windows 10



      • win 10 v 1903



_Android build issue:_

  • Node JS version

    • v10.16.0

  • Gradle version

    • 4.10.3 5.5 buildOutputCleanup vcs-1

Console output


console output

> Task :app:processReleaseResources
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:84: error: cannot find symbol
                FirebasePlugin.applicationContext = this.getApplicationContext();
                                                        ^
  symbol: method getApplicationContext()
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:196: error: no suitable constructor found for Intent(FirebasePluginMessagingService,Class<OnNotificationOpenReceiver>)
            Intent intent = new Intent(this, OnNotificationOpenReceiver.class);
                            ^
    constructor Intent.Intent(String,Uri) is not applicable
      (argument mismatch; FirebasePluginMessagingService cannot be converted to String)
    constructor Intent.Intent(Context,Class<?>) is not applicable
      (argument mismatch; FirebasePluginMessagingService cannot be converted to Context)
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:198: error: incompatible types: FirebasePluginMessagingService cannot be converted to Context 
            PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
                                                                     ^
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:208: error: incompatible types: FirebasePluginMessagingService cannot be converted to Context 
            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
                                                                                            ^
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:225: error: cannot find symbol
                    Uri soundPath = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/raw/" + sound);
                                                                                                ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:265: error: cannot find symbol
            int defaultSmallIconResID = getResources().getIdentifier(defaultSmallIconName, "drawable", getPackageName());
                                                                                                       ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:265: error: cannot find symbol
            int defaultSmallIconResID = getResources().getIdentifier(defaultSmallIconName, "drawable", getPackageName());
                                        ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:268: error: cannot find symbol
                customSmallIconResID = getResources().getIdentifier(icon, "drawable", getPackageName());
                                                                                      ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:268: error: cannot find symbol
                customSmallIconResID = getResources().getIdentifier(icon, "drawable", getPackageName());
                                       ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:279: error: cannot find symbol
                notificationBuilder.setSmallIcon(getApplicationInfo().icon);
                                                 ^
  symbol:   method getApplicationInfo()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:283: error: cannot find symbol
                int defaultLargeIconResID = getResources().getIdentifier(defaultLargeIconName, "drawable", getPackageName());
                                                                                                           ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:283: error: cannot find symbol
                int defaultLargeIconResID = getResources().getIdentifier(defaultLargeIconName, "drawable", getPackageName());
                                            ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:286: error: cannot find symbol
                    customLargeIconResID = getResources().getIdentifier(icon+"_large", "drawable", getPackageName());
                                                                                                   ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:286: error: cannot find symbol
                    customLargeIconResID = getResources().getIdentifier(icon+"_large", "drawable", getPackageName());
                                           ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:298: error: cannot find symbol
                    largeIconResID = getApplicationInfo().icon;
                                     ^
  symbol:   method getApplicationInfo()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:300: error: cannot find symbol
                notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), largeIconResID));
                                                                              ^
  symbol:   method getApplicationContext()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                                                                                           ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                                           ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                   ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:336: error: cannot find symbol
            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                                                                            ^
  symbol:   method getSystemService(String)
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:341: error: cannot find symbol
        FirebasePlugin.sendMessage(bundle, this.getApplicationContext());
                                               ^
  symbol: method getApplicationContext()
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
21 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileReleaseJavaWithJavac'.
> 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. Run with --scan to get full insights.

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

BUILD FAILED in 53s

> Task :app:compileReleaseJavaWithJavac

> Task :app:compileReleaseJavaWithJavac FAILED
33 actionable tasks: 33 executed
C:\Users\Simon\Development\core\mobile-app\platforms\android\gradlew: Command failed with exit code 1 Error output:
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:84: error: cannot find symbol
                FirebasePlugin.applicationContext = this.getApplicationContext();
                                                        ^
  symbol: method getApplicationContext()
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:196: error: no suitable constructor found for Intent(FirebasePluginMessagingService,Class<OnNotificationOpenReceiver>)
            Intent intent = new Intent(this, OnNotificationOpenReceiver.class);
                            ^
    constructor Intent.Intent(String,Uri) is not applicable
      (argument mismatch; FirebasePluginMessagingService cannot be converted to String)
    constructor Intent.Intent(Context,Class<?>) is not applicable
      (argument mismatch; FirebasePluginMessagingService cannot be converted to Context)
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:198: error: incompatible types: FirebasePluginMessagingService cannot be converted to Context 
            PendingIntent pendingIntent = PendingIntent.getBroadcast(this, id.hashCode(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
                                                                     ^
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:208: error: incompatible types: FirebasePluginMessagingService cannot be converted to Context 
            NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId);
                                                                                            ^
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:225: error: cannot find symbol
                    Uri soundPath = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/raw/" + sound);
                                                                                                ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:265: error: cannot find symbol
            int defaultSmallIconResID = getResources().getIdentifier(defaultSmallIconName, "drawable", getPackageName());
                                                                                                       ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:265: error: cannot find symbol
            int defaultSmallIconResID = getResources().getIdentifier(defaultSmallIconName, "drawable", getPackageName());
                                        ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:268: error: cannot find symbol
                customSmallIconResID = getResources().getIdentifier(icon, "drawable", getPackageName());
                                                                                      ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:268: error: cannot find symbol
                customSmallIconResID = getResources().getIdentifier(icon, "drawable", getPackageName());
                                       ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:279: error: cannot find symbol
                notificationBuilder.setSmallIcon(getApplicationInfo().icon);
                                                 ^
  symbol:   method getApplicationInfo()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:283: error: cannot find symbol
                int defaultLargeIconResID = getResources().getIdentifier(defaultLargeIconName, "drawable", getPackageName());
                                                                                                           ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:283: error: cannot find symbol
                int defaultLargeIconResID = getResources().getIdentifier(defaultLargeIconName, "drawable", getPackageName());
                                            ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:286: error: cannot find symbol
                    customLargeIconResID = getResources().getIdentifier(icon+"_large", "drawable", getPackageName());
                                                                                                   ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:286: error: cannot find symbol
                    customLargeIconResID = getResources().getIdentifier(icon+"_large", "drawable", getPackageName());
                                           ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:298: error: cannot find symbol
                    largeIconResID = getApplicationInfo().icon;
                                     ^
  symbol:   method getApplicationInfo()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:300: error: cannot find symbol
                notificationBuilder.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), largeIconResID));
                                                                              ^
  symbol:   method getApplicationContext()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                                                                                           ^
  symbol:   method getPackageName()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                                           ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:305: error: cannot find symbol
                int defaultColor = getResources().getColor(getResources().getIdentifier("accent", "color", getPackageName()), null);
                                   ^
  symbol:   method getResources()
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:336: error: cannot find symbol
            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                                                                            ^
  symbol:   method getSystemService(String)
  location: class FirebasePluginMessagingService
C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\firebase\FirebasePluginMessagingService.java:341: error: cannot find symbol
        FirebasePlugin.sendMessage(bundle, this.getApplicationContext());
                                               ^
  symbol: method getApplicationContext()
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Users\Simon\Development\core\mobile-app\platforms\android\app\src\main\java\org\apache\cordova\file\AssetFilesystem.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
21 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileReleaseJavaWithJavac'.
> 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. Run with --scan to get full insights.

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

BUILD FAILED in 53s
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd build android --release --buildConfig C:\Users\Simon\Development\cor... exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.




android build issue support

Most helpful comment

In recent Cordova versions you should now define plugins only in package.json not config.xml

All 5 comments

It looks to me like the plugin is not installed properly or is conflicting with another plugin in your project.

Try building the example project to validate your build environment and rule out possible causes specific to your project such as plugin conflicts.

The example project worked as expected.
I added all of my plugins to the example project and the build still works.

Clean installed everything on my production app but with no luck. The build error remains.
Is there any known error building thorugh cli/ionic on android similiar to #326 ?

Is there any known error building thorugh cli/ionic on android similiar to #326 ?

No, that's specific to iOS

If the build works with the example project with the same plugins, that suggests to me that there's an issue specific to your project. Make sure to clear down platforms/, node_modules/, and plugins/ and rebuild the project from scratch.

That did not help, but I found the problem:

Turns out that i had the following in my config.xml defined <plugin name="cordova-plugin-firebasex" spec="~6.1.0" />

Removed that line, rebuild everything and it worked (almost). I than ran into the 64k limit but after installing cordova-plugin-enable-multidex everything works now!

Guess I should not define any plugins in the config.xml anymore and only store them in the package.json. Or is that a bad practice?

In recent Cordova versions you should now define plugins only in package.json not config.xml

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EinfachHans picture EinfachHans  ·  5Comments

xurdep picture xurdep  ·  5Comments

hastom picture hastom  ·  6Comments

almothafar picture almothafar  ·  5Comments

satyam41295 picture satyam41295  ·  4Comments