3

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
1
  • Have you added android integration described at the package readme? Commented Oct 1, 2019 at 18:31

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, It's work for me. But I change the versions to firebase_messaging: 5.0.0.
The second solution is work for me, then execute Flutter Upgrade option on the pubspec.yaml
0

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

1 Comment

You should post your answer as a comment under @Maddy answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.