I Couldn't Trigger Sound Alert After User's Action On Flutter (based On Kotlin Error After AudioPlayers Package Added)

- 1 answer

I'm working on a Flutter project for an Android application. I need to give sound alerts when the user's action is completed success or wrong.

I've tried the AudioPlayers package but it didn't work.

version: audioplayers: ^0.20.1

playMusic() async {
    await, isLocal: true);

I even couldn't build the project after adding audioplayers.

enter image description here

Is there any other package for this?



When I added to AudioPlayers package to pubseck.yaml It was giving Kotlin error.

First I change my Kotlin version to 1.5.10 from 1.30.50 in 'android/build.gradle'.

ext.kotlin_version = '1.5.10'

And then the app started to give multidex errors.

I changed the configuration of 'android/app/build.gradle' like below

dependencies {
        compile ''

    defaultConfig {
        // TODO: Specify your own unique Application ID (
        applicationId "com.example.allstore_mobile"
        minSdkVersion 20
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true

After the above changes, the AudioPlayers package started to work.

final AudioCache _audioCache = AudioCache(
    prefix: 'assets/sounds/',
    fixedPlayer: AudioPlayer()..setReleaseMode(ReleaseMode.STOP),