Why does the Flutter build failed with the error Could not resolve all files for configuration ':app:debugRuntimeClasspath'

Issue

I wanted to use the flutter video_payer api for displaying a video from the network in my app. I upgraded to the latest version and now, my app won’t build. The following error is being displayed-

PBI: {"kind":"error","text":"Invoke-customs are only supported starting with Android O (--min-api 26)","sources":[{}],"tool":"D8"}

AGPBI: {“kind”:”error”,”text”:”Invoke-customs are only supported starting with Android O (–min-api 26)”,”sources”:[{}],”tool”:”D8″}
AGPBI: {“kind”:”error”,”text”:”Invoke-customs are only supported starting with Android O (–min-api 26)”,”sources”:[{}],”tool”:”D8″}
AGPBI: {“kind”:”error”,”text”:”Default interface methods are only supported starting with Android N (–min-api 24): void com.google.android.exoplayer2.Player$EventListener.onLoadingChanged(boolean)”,”sources”:[{}],”tool”:”D8″}
*********************************************************
WARNING: This version of video_player will break your Android build if it or its dependencies aren’t compatible with AndroidX.
See for more information on the problem and how to fix it.
This warning prints for all Android build failures. The real root cause of the error may be unrelated.
*********************************************************
AGPBI: {“kind”:”error”,”text”:”Default interface methods are only supported starting with Android N (–min-api 24): void com.google.android.exoplayer2.Player$EventListener.onLoadingChanged(boolean)”,”sources”:[{}],”tool”:”D8″}

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not resolve all files for configuration ‘:app:debugRuntimeClasspath’.

    Failed to transform file ‘classes.jar’ to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=16} using transform DexingTransform
    Error while dexing.
    The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle
    android {
    compileOptions {
    sourceCompatibility 1.8
    targetCompatibility 1.8
    }
    }
    See https://developer.android.com/studio/write/java8-support.html for details. Alternatively, increase the minSdkVersion to 26 or above.

Failed to transform file ‘classes.jar’ to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=16} using transform DexingTransform
Error while dexing.
The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
See https://developer.android.com/studio/write/java8-support.html for details. Alternatively, increase the minSdkVersion to 26 or above.

Failed to transform file ‘classes.jar’ to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=16} using transform DexingTransform
Error while dexing.
The dependency contains Java 8 bytecode. Please enable desugaring by adding the following to build.gradle
android {
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
See https://developer.android.com/studio/write/java8-support.html for details. Alternatively, increase the minSdkVersion to 26 or above.

Failed to transform file ‘classes.jar’ to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=16} using transform DexingTransform
Error while dexing.
Failed to transform file ‘classes.jar’ to match attributes {artifactType=android-dex, dexing-is-debuggable=true, dexing-min-sdk=16} using transform DexingTransform
Error while dexing.

  • 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 12s
Finished with error: Gradle task assembleDebug failed with exit code 1

I can’t figure out the issue. What seems to be the problem?

Solution

In the log, it says

The dependency contains Java 8 bytecode. Please enable desugaring by
adding the following to build.gradle android { compileOptions {
sourceCompatibility 1.8 targetCompatibility 1.8 } }

If you are using Java 8, add below code to your android/app/build.gradle

android {
  ...
  // Configure only for each module that uses Java 8
  // language features (either in its source code or
  // through dependencies).
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }
}

If it doesn’t work, try with Java 10 (in your case)

android {
      ...
      // Configure only for each module that uses Java 8
      // language features (either in its source code or
      // through dependencies).
      compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_10
        targetCompatibility JavaVersion.VERSION_1_10
      }
    }

You can find more details here: https://developer.android.com/studio/write/java8-support

Answered By – Phuc Tran

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published