为什么 Flutter 构建失败并出现错误 Could not resolve all files for configuration ':app:debugRuntimeClasspath'

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

我想使用 flutter video_payer api 在我的应用程序中显示来自网络的视频。我升级到最新版本,但现在无法构建我的应用程序。正在显示以下错误-

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"} ****************************************************** ******* 警告:如果此版本的 video_player 或其依赖项与 AndroidX 不兼容,它将破坏您的 Android 构建。 有关该问题及其解决方法的更多信息,请参阅 。 对于所有 Android 构建失败都会打印此警告。错误的真正根本原因可能无关。 ****************************************************** ******* 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"}

失败:构建失败,出现异常。

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.

12 秒内构建失败 已完成并出现错误:Gradle 任务 assembleDebug 失败,退出代码为 1

我想不通这个问题。好像是什么问题?

在日志中,它说

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

如果您使用的是 Java 8,请将以下代码添加到您的 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
  }
}

如果它不起作用,请尝试使用 Java 10(在您的情况下)

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
      }
    }

您可以在此处找到更多详细信息:https://developer.android.com/studio/write/java8-support