Error of compilation after add firebase messaging

1,007

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.

Share:
1,007
charlet pierre
Author by

charlet pierre

Updated on December 14, 2022

Comments

  • charlet pierre
    charlet pierre over 1 year

    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
    
    • Stel
      Stel over 4 years
      Have you added android integration described at the package readme?
  • charlet pierre
    charlet pierre over 4 years
    Thanks, It's work for me. But I change the versions to firebase_messaging: 5.0.0.
  • dmotta
    dmotta over 4 years
    The second solution is work for me, then execute Flutter Upgrade option on the pubspec.yaml
  • Marco Alves
    Marco Alves over 4 years
    You should post your answer as a comment under @Maddy answer