I am getting this error whenever I am trying to run my app,it was working fine yesterday then it just started doing this.
Launching lib\main.dart on SM M025F in debug mode...
lib\main.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)
CodePudding user response:
It turns out this comes from the minSdkVersion used. If this is set to 20 or lower, you need to configure your app for multiDex support.
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 30
}
So, if you app is not intended to be used in Android version prior to 5.0, setting the minSdkVersion number to 21
will easily fix this issue.
CodePudding user response:
I would clear Android Studio cache by going to File --> Invalidate Caches and rebuild Gradle file.
Check this video for gradle.