Flutter Execution failed for task ':audioplayers:compileDebugKotlin' - flutter

I tried installing audioplayers: ^0.17.1 and ran my flutter project. It throws the following error. Can someone help, please?
e: C:\Users\User\flutter\.pub-cache\hosted\pub.dartlang.org\audioplayers-0.17.1\android\src\main\kotlin\xyz\luan\audioplayers\AudioplayersPlugin.kt: (181, 52): Expecting a parameter declaration
e: C:\Users\User\flutter\.pub-cache\hosted\pub.dartlang.org\audioplayers-0.17.1\android\src\main\kotlin\xyz\luan\audioplayers\AudioplayersPlugin.kt: (231, 38): Expecting an argument
e: C:\Users\User\flutter\.pub-cache\hosted\pub.dartlang.org\audioplayers-0.17.1\android\src\main\kotlin\xyz\luan\audioplayers\ByteDataSource.kt: (8, 37): Expecting a parameter declaration
e: C:\Users\User\flutter\.pub-cache\hosted\pub.dartlang.org\audioplayers-0.17.1\android\src\main\kotlin\xyz\luan\audioplayers\WrappedMediaPlayer.kt: (10, 39): Expecting a parameter declaration
e: C:\Users\User\flutter\.pub-cache\hosted\pub.dartlang.org\audioplayers-0.17.1\android\src\main\kotlin\xyz\luan\audioplayers\WrappedSoundPool.kt: (168, 32): Expecting a parameter declaration
e: C:\Users\User\flutter\.pub-cache\hosted\pub.dartlang.org\audioplayers-0.17.1\android\src\main\kotlin\xyz\luan\audioplayers\WrappedSoundPool.kt: (205, 26): Expecting an argument
e: C:\Users\User\flutter\.pub-cache\hosted\pub.dartlang.org\audioplayers-0.17.1\android\src\main\kotlin\xyz\luan\audioplayers\WrappedSoundPool.kt: (46, 77): Type inference failed. Expected type mismatch: inferred type is List<???> but MutableList<WrappedSoundPool> was expected
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':audioplayers: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 37s
Exception: Gradle task assembleDebug failed with exit code 1

I had been struggling with this issue since morning and finally here are 2 fixes:
Upgrade to flutter 2.0 and then update audioplayers dependency to 0.19.0 in pubspec.yaml
*in the build.gradle change ext.kotlin_version to '1.4.32'
or
If you don't want to upgrade to flutter 2.0 due to some reasons then downgrade your audioplayers dependency to ^0.16.0.
Note: To update Flutter SDK use the flutter upgrade command.

The current latest version is 0.18.0, but I faced the same problem. And I could solve that problem by following Gradle Build Failing.
In order to support the playBytes method, this has a hard requirement on using API >= 23 features, and your build may failure depending on your minimum SDK targeting. To override this, you will need to add
<uses-sdk tools:overrideLibrary="xyz.luan.audioplayers"/> to your AndroidManifest.xml file.
If you still facing an error on the compiling, you should change version of kotline following this issue.
faced same issue, fixed by updating ext.kotlin_version to 1.4.31 in android/build.gradle.

Downgrade your audioplayers dependency to ^0.16.0

Open C:\Users\User\flutter.pub-cache\hosted\pub.dartlang.org\audioplayers-0.17.1\android\src\main\kotlin\xyz\luan\ folder and delete it.
It helps me

Related

I am getting a failed build while running my project

I just upgraded my Android Studio and flutter SDK. When I try running my flutter project I keep getting this error below. I am using flutter_paystack: ^1.0.5+1 package.
Parameter format not correct -
e: C:\src\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_paystack-1.0.5+1\android\src\main\kotlin\co\paystack\flutterpaystack\FlutterPaystackPlugin.kt: (48, 62): Type mismatch: inferred type is Activity? but Activity was expected
e: C:\src\flutter\flutter\.pub-cache\hosted\pub.dartlang.org\flutter_paystack-1.0.5+1\android\src\main\kotlin\co\paystack\flutterpaystack\MethodCallHandlerImpl.kt: (19, 37): Type mismatch: inferred type is BinaryMessenger? but BinaryMessenger was expected
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_paystack: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.
Please what might be the cause
package flutter_paystack: 1.0.5+1 not work on flutter 3
try change dependency of flutter_paystack 1.0.5+1 in pubspec.yaml to:
flutter_paystack:
git:
url: https://github.com/definitelyme/flutter_paystack.git
ref: a4a33c3dd0a12f46d655a2e63d11e9f20ba82d01
Go to your android/build.gradle file and update your Kotlin version hope its help to you.
ext.kotlin_version = '1.6.10'
This is mostly a problem with the Flutter version 3.
The best bet you have is to downgrade your flutter to version 2.x.x
This might conflict with other plugins you're using(like I experienced).
So you might as an alternative. Try embedding paystack payment in a webview. Create a web page, integrate paystack. Call that web page in a webview embedded in the app.
It might even be better if you're looking for extra payment options like bank transfer which isn't available on the flutter app plugin.

pubpspect get failed when adding flutter_html lib in flutter

I have tried to build app 'flutter_html: ^2.1.5" but I unable to build and getting below error in log.
The current Flutter SDK version is 1.27.0-2.0.pre.1.
Because flutter_app depends on flutter_html >=2.1.0 which requires Flutter SDK version >=2.2.0, version solving failed.
pub get failed (1; Because flutter_app depends on flutter_html >=2.1.0 which requires Flutter SDK version >=2.2.0, version solving failed.)
can you suggest the way to clear this issue?
I have upgraded flutter version and migrated and having different issue.
FAILURE: Build failed with an exception.
* What went wrong:
A problem was found with the configuration of task ':app:checkDebugManifest' (type 'CheckManifest').
- In plugin 'com.android.build.gradle.api.AndroidBasePlugin' type 'com.android.build.gradle.internal.tasks.CheckManifest' property 'manifest' has #Input annotation used on property of type 'File'.
Reason: A property of type 'File' annotated with #Input cannot determine how to interpret the file.
Possible solutions:
1. Annotate with #InputFile for regular files.
2. Annotate with #InputDirectory for directories.
3. If you want to track the path, return File.absolutePath as a String and keep #Input.
Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#incorrect_use_of_input_annotation for more details about this problem.
* 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 11s
Exception: Gradle task assembleDebug failed with exit code 1
You need to upgrade your flutter SDK. Write flutter upgrade in terminal.
Or use an older version of flutter_html.

gradle build failure Execution failed for task ':webview_flutter:compileDebugJavaWithJavac'

My flutter app doesn't even have webview_flutter plugin and it's showing error for that. Gradle build failure. First it told me to set minSDkVersion to 19. I did that but still error. I had the same app but different project running before with exact same code and plugins. I don't understand what's going on. Please help.
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
Note: C:\flutter\.pub-cache\hosted\pub.dartlang.org\thumbnails-
1.0.1\android\src\main\java\com\asapjay\thumbnails\ThumbnailsPlugin.java uses or overrides a
deprecated API.
Note: Recompile with -Xlint:deprecation for details.
C:\flutter\.pub-cache\hosted\pub.dartlang.org\webview_flutter-
2.0.6\android\src\main\java\io\flutter\plugins\webviewflutter\InputAwareWebView.java:31: error:
cannot find symbol
private ThreadedInputConnectionProxyAdapterView proxyAdapterView;
^
symbol: class ThreadedInputConnectionProxyAdapterView
location: class InputAwareWebView
C:\flutter\.pub-cache\hosted\pub.dartlang.org\webview_flutter-
2.0.6\android\src\main\java\io\flutter\plugins\webviewflutter\InputAwareWebView.java:112: error:
cannot find symbol
new ThreadedInputConnectionProxyAdapterView(
^
symbol: class ThreadedInputConnectionProxyAdapterView
location: class InputAwareWebView
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
2 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':webview_flutter: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 44s
Exception: Gradle task assembleDebug failed with exit code 1
ThreadedInputConnectionProxyAdapterView has wrong extension .jav
You can just change it to .java by hand as a temporary fix.
or
I temporarily downgraded webview_flutter back to 2.0.4. (after downgrading webview_flutter if this solution not working then you need to check your pubsepc.lock file for webview_flutter, because some other dependencies may extend webview_flutter so this package will visible in pubsepc.lock file, then you just need downgrade webview_flutter from this file also)
Enjoy!
This happen because of the webview_flutter package version issue. I have downgrade the version and it worked. Go to the pubspec.yaml and downgrade the version to 2.0.14

Flutter Error: No named parameter with the name 'keyboardDismissBehavior'

The flutter project ran well on my android device before i ran flutter grade command. And then the project just cant run anyway without any code change. Here is the error message:
Launching lib/main.dart on RMX1971 in debug mode...
Running Gradle task 'assembleDebug'...
../../env/flutter/.pub-cache/hosted/pub.flutter-io.cn/pull_to_refresh-1.6.4/lib/src/smart_refresher.dart:434:9: Error: No named parameter with the name 'keyboardDismissBehavior'.
keyboardDismissBehavior:
^^^^^^^^^^^^^^^^^^^^^^^
../../env/flutter/packages/flutter/lib/src/widgets/scroll_view.dart:588:9: Context: Found this candidate, but the arguments don't match.
const CustomScrollView({
^^^^^^^^^^^^^^^^
FAILURE: Build failed with an exception.
Where:
Script '/Users/lgk/env/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 907
What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command '/Users/lgk/env/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 14s
Exception: Gradle task assembleDebug failed with exit code 1
This is actually a compatibility issue between pull_to_refresh plugin and the current version of Flutter during this time. There are some bugs related to this and most of the solutions were found on the thread:
https://github.com/peng8350/flutter_pulltorefresh/issues/427
https://github.com/peng8350/flutter_pulltorefresh/issues/424
To summarized the solution from this thread:
How to solve Error: No named parameter with the name 'keyboardDismissBehavior' ?
to solve Error: No named parameter
with the name 'keyboardDismissBehavior' This error is caused due to
pull_to_refresh plugin that you are using in your flutter app is not
compatible with the current version of flutter. The solution is just
downgraded your plugin version.
Error: No named parameter with the name 'keyboardDismissBehavior
to solve Error: No named parameter with
the name 'keyboardDismissBehavior' This error is caused due to
pull_to_refresh plugin that you are using in your flutter app is not
compatible with the current version of flutter. The solution is just
downgraded your plugin version.
Solution 1
This error is cause due to pull_to_refresh plugin that you are using
in your flutter app that is not compatible with the current version of
flutter. The solution is just to downgrade your plugin version. Just
Follow below step to solve this error.
Edit file pubspec.yaml
Change This Line pull_to_refresh ^1.6.4 or pull_to_refresh ^1.6.3
Replace with pull_to_refresh 1.6.3
run flutter clean
flutter run
Solution 2
pull_to_refresh plugin is not compatible with the current version of
flutter.

Error of compilation after add firebase messaging

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