FAILURE: Build Failed,运行app时出现异常错误



每当我试图运行我的应用程序时,我都会得到这个错误,它昨天工作得很好,然后它才开始这样做。

Launching libmain.dart on SM M025F in debug mode...
libmain.dart:1
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform classes.jar (project :fluttertoast) to match attributes {artifactType=android-dex, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.api.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-incremental-transform=false, dexing-is-debuggable=true, dexing-min-sdk=16, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=androidJvm}.
> Could not isolate parameters com.android.build.gradle.internal.dependency.JetifyTransform$Parameters_Decorated@4914359b of artifact transform JetifyTransform
> Current thread does not hold the state lock for project :app
* 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 44s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

事实证明这来自使用的minSdkVersion。如果该值设置为20或更低,则需要配置应用程序支持multiDex。

defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 30
}

所以,如果你的应用程序不打算在5.0之前的Android版本中使用,设置minSdkVersion number to 21将很容易解决这个问题。

我将清除Android Studio缓存通过文件->

查看gradle的视频

最新更新