Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to build APK due the package "Audioplayers"

Tags:

flutter

dart

I am using the package Flutter audio players in my app to play audio from Google Cloud TTS. It is working fine on the iOS simulator, but when I build the APK, it gives the following error:

e: /Users/josuha/Documents/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: /Users/joshua/Documents/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: /Users/joshua/Documents/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: /Users/joshua/Documents/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: /Users/joshua/Documents/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: /Users/joshua/Documents/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: /Users/joshua/Documents/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:compileReleaseKotlin'.         
> 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 7s                                                      
Running Gradle task 'assembleRelease'...                                
Running Gradle task 'assembleRelease'... Done                       8.7s
Gradle task assembleRelease failed with exit code 1
like image 918
Joshua Avatar asked Jan 02 '21 14:01

Joshua


Video Answer


3 Answers

As far as I can see, it's a bug.

As with all bugs, you can wait for a fix or you can downgrade the package until you find a version where it still worked.

Alternatively, you can dig into the code yourself, fix it and open a pull request.

like image 171
nvoigt Avatar answered Oct 19 '22 23:10

nvoigt


you can try upgrade ext.kotlin_version to '1.4.21' on the build.gradle It work for me!. Github Discussion

like image 28
Teja Avatar answered Oct 20 '22 00:10

Teja


As @Teja correctly pointed out, the error was that your project is using an outdated version of kotlin that didn't support some features like trailing commas.

The real fix is to update your app configuration (explained above).

However, to avoid confusion I merged this PR that also downgrades our code so that it works on old versions of kotlin. That has been merged and released on 0.17.3 and up (currently we are at 0.17.4).

Therefore, this is fixed. There is no reason to downgrade AP anymore on your apps.

like image 1
Luan Nico Avatar answered Oct 19 '22 22:10

Luan Nico