Error of compilation after add firebase messaging - flutter

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

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.

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

Related

FAILURE: Build failed with an exception. * Where: Script gradle\flutter.gradle' line: 1165

I developed an application using the flutter web emulator, after the application was finished I made it I want to run to the Android emulator, but there is an error like this
FAILURE: Build failed with an exception.
Where:
Script 'C:\Users\Denis\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1165
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\Users\Denis\flutter\bin\flutter.bat'' finished with non-zero exit value 1
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 12s
Exception: Gradle task assembleDebug failed with exit code 1
previously the error was on line 1005, then I did a flutter upgrade and now the error is on line 1165
The error message you received is not very specific and can occur due to various reasons. However, the fact that the error message is referring to Gradle suggests that there is an issue with the build process of your application. Here are a few steps that you can follow to try and resolve the issue:
Check the logs: When you run the 'flutter run' command, you should see a log output in your terminal or console. Look for any error messages that may provide more details about the issue.
Clean the project: Sometimes, cleaning the project can help resolve build issues. To do this, run the following commands:
flutter clean
flutter pub get
Update dependencies: Make sure that all dependencies in your pubspec.yaml file are up to date. You can do this by running the following command:
flutter pub upgrade
Check your code: Look for any errors in your code that may be causing the build to fail. Check the line number mentioned in the error message and see if there are any issues with the code on that line. 5. Check your Gradle configuration: If none of the above steps work, you may need to check your Gradle configuration. Make sure that you have the latest version of Gradle installed and that your build.gradle file is correctly configured. If you are still unable to resolve the issue, try searching for the error message online or consider seeking help from the Flutter community or support.

erron on vscode gradle

i have one error that's is impossible for me to solve, what kind of problem is this shit?
I've searched for many ways to fix this but i don't have found it nothing for this problem on vscode only for android studio, someone can help me?
enter image description here
this impossibilite me to deploy my application in a on virtual android always stop in this error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.ResourceCompilerRunnable
> Resource compilation failed. Check logs 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 4s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
You should run
flutter run --verbose
and try to upload new image error.
I've found it whats happening man,in flutter in pub dev they gave changed the ways of splash screen it's not using the drawables anymore,we must create in lib paste the archive called Splash-Screen.dart and code all the splash screen rsrsrs but i'll appreciate your bro,and i'm very thankfull for that.

Error: Type mismatch: inferred type is Activity? but Activity was expected - Flutter

When starting the application I get the following errors in the console:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
lib\main.dart:1
e: C:\src\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_app_restart-1.0.0\android\src\main\kotlin\com\example\flutter_app_restart\FlutterRestartPlugin.kt: (55, 18): Type mismatch: inferred type is Activity? but Activity was expected
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_app_restart:compileDebugKotlin'.
> Compilation error. See log for more 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
BU�LD FAILED in 42s
How can I solve it? Thank you in advance for the help.
Goto the FlutterRestartPlugin.kt file and replace all the Activity with Activity? except package name and comment.
This clearly seems to be an issue in the flutter_app_restart package that you are using. Maybe check the package's issue page for a solution here.
Also, that package seems to be a very new pakcage with no real documentation. If it is pragmatic restart of the app you are seeking, you are better off using something like flutter_phoenix package. You can find it here.

No named parameter with the name interactive

When I run my flutter application on android studio this error appear, I did flutter clean and many commands but it didn't work.
../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/dropdown_search-0.6.3/lib/src/selectDialog.dart:193:23: Error: No named parameter with the name 'interactive'.
interactive: widget.scrollbarProps?.interactive,
^^^^^^^^^^^
../../snap/flutter/common/flutter/packages/flutter/lib/src/material/scrollbar.dart:63:9: Context: Found this candidate, but the arguments don't match.
const Scrollbar({
^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script '/home/saava/snap/flutter/common/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 991
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/home/saava/snap/flutter/common/flutter/bin/flutter'' finished with non-zero exit value 1
* 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 4m 41s
The interactive property of Scrollbar was added in Flutter 2.2. If you are using a version older than that, this package (or at least this version of the package) won't work for you. The package's release notes don't make it clear which version you should be using, though, but it will probably be some point from 0.5.0 onward since that was the release which supported null safety which corresponds to Flutter 2.0.
Alternatively, you can just update your version of Flutter to 2.2+. (At time of writing, the latest version of Flutter on the stable channel is 2.2.2.)

I always fail to run with an error description in the flutter contact picker

This problem only exists when I run it on Android, for iOS there is no problem, I run it smoothly.
This is an error display when I try to run it :
e: /Users/yohanescatur/Documents/Development/flutter/.pub-cache/hosted/pub.dartlang.org/fluttercontactpicker-4.2.1/android/src/main/kotlin/me/schlaubi/fluttercontactpicker/ContactPicker.kt: (52, 280): Unresolved reference: stackTraceToString
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':fluttercontactpicker:compileDebugKotlin'.
Compilation error. See log for more 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 28s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)
can you help me find this problem?
set kotlin to 1.4.21
this is what i did to solve this problem.
set kotlin to 1.5.10
this is what i did to solve this problem.
please flutter clean and pub get after upgrade kotlin version