0

My app uses audio_players to play audio. It runs fine on the ios simulator but when I try to build the apk to run the app on a physical device I get the following error:

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/joshua/.pub-cache/hosted/pub.dev/audioplayers_android-2.0.0/android/build.gradle' line: 29

* What went wrong:
A problem occurred evaluating project ':audioplayers_android'.
> Failed to apply plugin [id 'de.mannodermaus.android-junit5']
   > android-junit5 plugin requires Gradle 6.1.1 or later

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* Where:
Script '/Users/joshua/Documents/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 463

* What went wrong:
A problem occurred configuring project ':audioplayers_android'.
> Failed to notify project evaluation listener.
   > Cannot invoke method substring() on null object
   > compileSdkVersion is not specified.

* 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 1m 56s
Running Gradle task 'assembleRelease'...                          118.0s
Gradle task assembleRelease failed with exit code 1
Joshua
  • 249
  • 4
  • 16

1 Answers1

0

The error message suggests that there are two problems preventing you from building the APK for your app. The first problem is related to the android-junit5 plugin, which requires a newer version of Gradle. The second problem is related to the audioplayers_android plugin, which is failing to configure the project due to a missing compileSdkVersion.

To address the first issue, you can update the version of Gradle in your project. You can do this by modifying the build.gradle file in the root of your project and updating the classpath for the Gradle plugin. For example:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2' // the gradel is updated to 8.0.2
        classpath 'de.mannodermaus.gradle.plugins:android-junit5:1.7.1.1'
    }
}

To address the second issue, you need to specify a compileSdkVersion in your build.gradle file for the audioplayers_android plugin. For example:

android {
    compileSdkVersion 31
    ...
}
Shashank Deepak
  • 163
  • 1
  • 8