Skip to content

Execution failed for task ':audioplayers_android:compileReleaseKotlin'. #1568

@wujek-srujek

Description

@wujek-srujek

Checklist

  • I read the troubleshooting guide before raising this issue
  • I made sure that the issue I am raising doesn't already exist

Current bug behaviour

The Android app of my project stops building as soon as I add audioplayers as a dependency. Something is wrong with the combination of Java version, AGP version, Kotlin version (which I'm trying to upgrade).

  • I'm building with Java 17:
$ java --version
openjdk 17.0.6 2023-01-17
OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)
OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode)
  • My main build.gradle has these dependencies (otherwise unchanged form the default one generated by flutter create:
    dependencies {
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.22'
        classpath 'com.android.tools.build:gradle:8.0.2'
    }
  • The 'app' module build.gradle is unchanged form the default except for a bump in the min SDK version. The relevant seems to be Java/Kotlin bytecode compatibility settings, which are:
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = '1.8'
    }

When I execute flutter build apk, it fails with the following error:

$ flutter build apk


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':audioplayers_android:compileReleaseKotlin'.
> 'compileReleaseJavaWithJavac' task (current target is 1.8) and 'compileReleaseKotlin' task (current target is 17) jvm target compatibility should be set to the same Java version.
  Consider using JVM toolchain: https://kotl.in/gradle/jvm/toolchain

When I remove audioplayers from the dependencies, the APK builds fine.

Expected behaviour

The APK builds fine with audioplayers.

Steps to reproduce

  1. Use the basic project provided as attachment to this report. build_failure_audioplayers.zip
  2. Unzip, go to the main folder, run flutter pub get to get all the necessary files.
  3. Run flutter build apk and see it fail.
  4. In pubspec.yaml, remove / comment out the audioplayers dependency and run flutter build apk again - see it work.

Affected platforms

Android

AudioPlayers Version

5.1.0

Build mode

debug, profile, release

Working on PR

no way

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions