0

How can I fix this logcat error in flutter when i added local_auth: ^2.1.2 to my project

Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)
     Duplicate class androidx.lifecycle.ViewTreeViewModelKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.5.1-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.1)

Here is the kotlin plugin added by default in the build gradle file

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

So i can,t really tell where the error is coming from i have tried to clean, rebuild the project and also invalidate and restart andriod studio but the error still persists. Any advice will be greatly appreciated. Thanks

1 Answers1

0
  1. Go to gradle.properties(project properties)

  2. Add

    android.enableJetifier=true

  3. And also most of time android.useAndroidX=true is present.Check your gradle.properties(Project Properties) and if it does not exist then add android.useAndroidX=true