I'm using cordova-plugin-firebase
to manage push notifications in my Ionic 2+ app.
I was able to configure and receive notifications on iOS, but I have the following error on Android.
/Users/Andrea/Progetti/ionic-app/platforms/android/app/src/main/java/org/apache/cordova/firebase/FirebasePluginMessagingService.java:120: error: constructor Builder in class Builder cannot be applied to given types;
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, channelId)
^
required: Context
found: FirebasePluginMessagingService,String
reason: actual and formal argument lists differ in length
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.
1 errorFAILURE: 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
I'm using version 1.0.4 of cordova-plugin-firebase
and version 7.0.0 of cordova-android
.
It's worth noting that I was able to build the app with version 6.4.0 of cordova-android
: the error arose when I had to update it to version 7.0.0.
Any help would be really appreciated.
@avalloneandrea have you tested with cordova-android 7.1.0
?
I have just removed the platform, updated cordova-android
to version 7.1.0 and tested again: the problem persists.
The issue could be an incompatibility with some other plugins. Here is a list of plugins apparently incompatible with cordova-plugin-firebase
:
I'm using cordova-android-support-gradle-release
to fix android-support version to 25.+
:
<plugin name="cordova-android-support-gradle-release" spec="1.3.0">
<variable name="ANDROID_SUPPORT_VERSION" value="25.+" />
</plugin>
Today, I tried to add cordova-plugin-firebase
plugin on my app, and I got the exact same issue while trying to compile cordova-plugin-firebase
My cordova platform info
:
Installed platforms:
android 6.4.0
browser 4.1.0
ios 4.5.2
My cordova plugin info
:
cordova-android-play-services-gradle-release 1.3.0 "cordova-android-play-services-gradle-release"
cordova-android-support-gradle-release 1.1.1 "cordova-android-support-gradle-release"
cordova-background-geolocation 2.7.3 "BackgroundGeolocation"
cordova-custom-config 2.0.3 "cordova-custom-config"
cordova-plugin-background-fetch 5.1.1 "CDVBackgroundFetch"
cordova-plugin-cocoalumberjack 0.0.4 "CocoaLumberjack"
cordova-plugin-compat 1.2.0 "Compat"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-dialogs 1.3.3 "Notification"
cordova-plugin-file 6.0.1 "File"
cordova-plugin-file-opener2 2.0.19 "File Opener2"
cordova-plugin-file-transfer 1.7.1 "File Transfer"
cordova-plugin-firebase 1.0.5 "Google Firebase Plugin"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-google-analytics 1.7.11 "Google Universal Analytics Plugin"
cordova-plugin-inappbrowser 1.7.0 "InAppBrowser"
cordova-plugin-network-information 1.2.1 "Network Information"
cordova-plugin-request-location-accuracy 2.2.2 "Request Location Accuracy"
cordova-plugin-splashscreen 3.2.2 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-whitelist 1.3.2 "Whitelist"
cordova.plugins.diagnostic 3.7.0 "Diagnostic"
phonegap-plugin-barcodescanner 6.0.4 "BarcodeScanner"
By looking at NotificationCompat.Builder documentation it appears that constructor taking context
and channelId
was introduced in [email protected]
I upgraded my cordova-android-support-gradle-release
's ANDROID_SUPPORT_VERSION
variable from 25.+
to 26.+
and it worked
Note - just expanding on the comment by @fcamblor
I needed to update the ANDROID_SUPPORT_VERSION variable in the config.xml file and the package.json file (for an Ionic app)
Had the same issue.
Upgrading to ANDROID_SUPPORT_VERSION
to 26.+
worked.
closing as resolved
I got same issue while running 'ionic cordova run android'
I have checked the given ANDROID_SUPPORT_VERSION and it is 27+.
What can be the next?
I have same problem that @sahilr2050. How he, i have ANDROID_SUPPORT_VERSION and it is 27+.
Ionic info result:
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.1.1 ([email protected])
local packages:
@ionic/app-scripts : 3.2.2
Cordova Platforms : none
Ionic Framework : ionic-angular 3.9.5
System:
Node : v10.16.0
npm : 6.9.0
OS : macOS
Xcode : Xcode 10.2.1 Build version 10E1001
Environment Variables:
ANDROID_HOME : /Development/android-sdk/
Misc:
backend : pro
Please let me know when there is any solution for that I am unable to resolve this as I don't know how to do programming in JAVA
I could execute build my app following steps:
update ionic:
sudo npm uninstall -g ionic
sudo npm install -g ionic
update cordova:
sudo npm uninstall -g cordova
sudo npm install -g cordova
Remove the Android platform from the project:
ionic cordova platforms rm android
Remove node_modules and plugins folders
Reinstall the packages npm:
npm install
Add the platform android@8 again:
ionic cordova platforms add android@8
Install this plugins:
ionic cordova plugin add cordova-plugin-androidx-adapter
ionic cordova plugin add cordova-plugin-androidx
After add the plugin add this line in your gradle properties:
android.useAndroidX=true
android.enableJetifier=true
The solution about plugin androidx-adapter I found here.
See how my environment is now (ionic info):
Ionic:
Ionic CLI : 5.0.3
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.2
Cordova:
Cordova CLI : 9.0.0 ([email protected])
Cordova Platforms : android 8.0.0
Cordova Plugins : cordova-plugin-ionic-webview 1.2.1, (and 16 other plugins)
Utility:
cordova-res : not installed
native-run : 0.2.6
System:
ios-sim : 6.1.2
NodeJS : v10.16.0 (/usr/local/bin/node)
npm : 6.9.0
OS : macOS Mojave
Xcode : Xcode 10.2.1 Build version 10E1001
I hope helped you! Good lock
Still not working with above solution. @NadineAnderle
Do you want me to put ionic --info?
Which is error that you have? Still the same?
Please send me the error, ionic info and package.json
Thank you @NadineAnderle I had the same error and using the android-x adapter and following your instructions to remove and re-add node modules and android platform then install the plugin allowed me to build successfully again.
Hello @NadineAnderle ,
Thanks for providing your solution. It really works.
Actually, There was an issue in another plugin for version compatibility of play services. I have resolved that first and applied your solution and it works perfectly.
Thanks you so much for providing working solution.
Nothing is impossible when we have community with such kind of people. :)
Most helpful comment
By looking at NotificationCompat.Builder documentation it appears that constructor taking
context
andchannelId
was introduced in[email protected]
I upgraded my
cordova-android-support-gradle-release
'sANDROID_SUPPORT_VERSION
variable from25.+
to26.+
and it worked