Reputation: 55
For an applications development I need firebase cloud messaging. In my pubsepc.yaml I add this dependencies : firebase_messaging: ^5.1.6
I don't have add code for the moment.
Afterward I build code and I have error :
flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging-5.1.6/android/src/main/java/io/flutter/plugins/firebasemessaging/FlutterFirebaseMessagingService.java:143: error: method findAppBundlePath in class FlutterMain cannot be applied to given types;
String appBundlePath = FlutterMain.findAppBundlePath();
^
required: Context
found: no arguments
reason: actual and formal argument lists differ in length
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':firebase_messaging: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. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Finished with error: Gradle task assembleDebug failed with exit code 1
Upvotes: 3
Views: 1105
Reputation: 671
The answer of @Maddy is clear. But if someone is not solved the problem.
Please try: flutter upgrade
and do @Maddy answer
This works for me. Sorry about new thread answer, I don't have enough reputation
Upvotes: 0
Reputation: 5053
If you go to Java and check FlutterFirebaseMessagingService.java
FlutterMain.findAppBundlePath()
it required context in the argument here so 1st solution is here you can add context in the argument like this way
FlutterMain.findAppBundlePath(context)
The second solution remove firebase_messaging: ^5.1.6
dependency from pubspac.yaml
and hit flutter clean
in terminal to clean, now add firebase_messaging: 5.1.6
(without ^) and hit flutter pub get
in terminal. This solution works for me.
The second solution is the better practice.
Upvotes: 6