1

I started with flutter last week and I got this problem with the audioplayer package. I am doing a Flutter Development Bootcamp with Dart at Udemy. I followed almost everything at the video, but I recived a huge error message that I can't solve.

This is my code:

import 'package:flutter/material.dart';
import 'package:audioplayers/audioplayers.dart';
void main() => runApp(XylophoneApp());

class XylophoneApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        backgroundColor: Colors.lightBlue,
        body: SafeArea(
          child: Container(
            child: Center(
              child: TextButton(
                onPressed: (){
                  final player = AudioCache();
                  player.play('assets/note1');
                },
                child: Text(
                  'click me'
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

This is the error message that i get: Running Gradle task 'assembleDebug'... e: Incompatible classes were found in dependencies. Remove them from the classpath or use '-Xskip-metadata-version-check' to suppress errors e: C:/Users/victo/.gradle/caches/transforms-2/files-2.1/24fa3aa8d2270e5eb067bbe36e9b7563/jetified-kotlin-stdlib-1.5.10.jar!/META-INF/kotlin-stdlib.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15... (The message is much more larger than this)

  • 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 21s Exception: Gradle task assembleDebug failed with exit code 1

I've seen this message The binary version of its metadata is 1.5.1, expected version is 1.1.15, but I dont know what to do with it or how I can solve it.

This is my pubspec.yaml:

name: xylophone
description: A new Flutter application.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  audioplayers: ^0.19.1
  cupertino_icons: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter


flutter:

  uses-material-design: true

  assets:
    - assets/
Zanzini
  • 11
  • 3

2 Answers2

1

In gradle files, go to build.gradle (Project: YourApp). Then, change the following code (in buildscript):

from

ext.kotlin_version = '1.3.50'

to

ext.kotlin_version = '1.4.32'

or what ever the latest version of Kotlin available and make sure to update Kotlin version on Android Studio as well

After following the instructions, your error will be resolved.

kksal55
  • 358
  • 5
  • 13
0

You can look into error log Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.5.1, expected version is 1.1.15 but try to 1.3.50, i have app with audioplayer i am using this version if it doesn't work use 1.1.15 or the suggested version after changing version uninstall app and run flutter clean and run again

Try downgrade to a lower kotlin version in build.gradle

buildscript {
    ext.kotlin_version = '1.3.50'
    repositories {
        google()
        jcenter()
    }

}

Also refer this answers also if doesn't work in case

Abhijith
  • 1,939
  • 2
  • 12
  • 32
  • When I looked at the build.gradle it was already in the version '1.3.50', and i got that message again, than I changed it to '1.1.15' and still got an error, but a diferente one: * What went wrong: A problem occurred configuring root project 'android'. > Could not resolve all artifacts for configuration ':classpath'. > Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.15. – Zanzini Aug 11 '21 at 19:48
  • My gradle: buildscript { ext.kotlin_version = '1.1.15' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { google() jcenter() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" project.evaluationDependsOn(':app') } task clean(type: Delete) { delete rootProject.buildDir } – Zanzini Aug 11 '21 at 19:50
  • check this link https://stackoverflow.com/a/68061290/13418165 – Abhijith Aug 12 '21 at 04:54
  • Thanks for the help man, I was able to run the app – Zanzini Aug 15 '21 at 05:51