Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Execution failed for task ':audioplayers:compileDebugKotlin'

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
like image 757
Woon Mar Avatar asked Jan 04 '21 05:01

Woon Mar


2 Answers

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.

like image 64
master Gaurav Avatar answered Oct 20 '22 07:10

master Gaurav


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.

like image 38
takinok Avatar answered Oct 20 '22 08:10

takinok