cordova-plugin-firebase: Constructor Builder in class Builder cannot be applied to given types
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 error
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
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.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 16 (2 by maintainers)
By looking at NotificationCompat.Builder documentation it appears that constructor taking
context
andchannelId
was introduced inandroid-support@26.1.0
I upgraded my
cordova-android-support-gradle-release
’sANDROID_SUPPORT_VERSION
variable from25.+
to26.+
and it workedI have just removed the platform, updated
cordova-android
to version 7.1.0 and tested again: the problem persists.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. 😃
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.
Had the same issue. Upgrading to
ANDROID_SUPPORT_VERSION
to26.+
worked.