How to fix ':app:checkDebugDuplicateClasses' error in flutter [duplicate] - android

This question already has answers here:
Duplicate class androidx.lifecycle.ViewModelLazy found in modules lifecycle-viewmodel-2.5.0-runtime
(8 answers)
Closed 5 months ago.
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

Go to gradle.properties(project properties)
Add
android.enableJetifier=true
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

Related

Android Studio Dolphin 2021.3.1: Error while building project

I just recently upgraded from Arctic Fox to Dolphin and migrated my project from Gradle 7.0.3 to 7.3.0.
When I want to build project I got error:
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.4.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.4.0)
Duplicate class androidx.lifecycle.ViewModelProviderKt found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1) and lifecycle-viewmodel-2.4.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.4.0)
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.4.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.4.0)
My entire project is non-usable and broken right now.
This happened with me when I added the androidx.preference.preference-ktx:1.2.0
dependency in gradle.
Just add this dependency in build.gradle file to fix this.
Java ->
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.5.1'
Kotlin ->
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
This error occurs due to one of the dependencies having an explicit dependency of lifecycle 2.3.1.
Google Tracker Issue Link -> https://issuetracker.google.com/issues/242384116
Hope this helps :)

React Native - Android Animated WebP is not working

I am trying to play an animated webp file on android devices. I am using react-native-animated-webp package but I got an error while building the app.
When I added the following lines into app/build.gradle file:
implementation("com.facebook.fresco:fresco:2.0.0")
// For animated GIF support
implementation 'com.facebook.fresco:animated-gif:2.0.0'
// For WebP support, including animated WebP
implementation 'com.facebook.fresco:animated-webp:2.3.0'
implementation 'com.facebook.fresco:webpsupport:2.3.0'
I got this error :
* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
java.lang.RuntimeException: Duplicate class com.facebook.imagepipeline.cache.CountingMemoryCacheInspector found in modules imagepipeline-base-2.3.0-runtime.jar (com.facebook.fresco:imagepipeline-base:2.3.0) and stetho-2.0.0-runtime.jar (com.facebook.fresco:stetho:2.0.0)
Duplicate class com.facebook.imagepipeline.cache.CountingMemoryCacheInspector$DumpInfo found in modules imagepipeline-base-2.3.0-runtime.jar (com.facebook.fresco:imagepipeline-base:2.3.0) and stetho-2.0.0-runtime.jar (com.facebook.fresco:stetho:2.0.0)
Duplicate class com.facebook.imagepipeline.cache.CountingMemoryCacheInspector$DumpInfoEntry found in modules imagepipeline-base-2.3.0-runtime.jar (com.facebook.fresco:imagepipeline-base:2.3.0) and stetho-2.0.0-runtime.jar (com.facebook.fresco:stetho:2.0.0)
Is there anyone who faced this issue before? How can I solve it?
I upgraded Flipper Version to FLIPPER_VERSION=0.99.0 then Fresco version from 2.0.0 to 2.5.0 then cd android && ./gradlew clean it worked for me

org.gradle.api.UncheckedIOException: java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF

My code is work properly in android 9 only, before updated Gradle file is work properly after updating Gradle is showing error
less than version
org.gradle.api.UncheckedIOException: java.util.zip.ZipException: duplicate entry: META-INF/MANIFEST.MF
Some of your Libraries have similar dependencies
specifically jetbrains library check this Article

app:transformClassesWithJarMergingForDebug apk build issue

When I try to build apk android studio gives me this error.
Can anyone has any idea about this error?
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: permissions/dispatcher/GrantableRequest.class
If you are using PermissionsDispatcher library thn its mentioned as issue for duplicate class entry.
How to Check attached libraries Dependency/hierarchy ? which causes duplicate entry for libraries.
In your case you need to make changes as per mentioned in libraries known issue.
compile 'com.github.hotchemi:permissionsdispatcher:2.0.3'
compile 'com.github.hotchemi:permissionsdispatcher-processor:2.0.3'
Make changes as per below
compile 'com.github.hotchemi:permissionsdispatcher:2.0.3'
apt 'com.github.hotchemi:permissionsdispatcher-processor:2.0.3'
For more details on duplicate entry issue please check this
UPDATE
Its required to define apt dependecies in root level build.gradle file also
check this for root level build.gradle file declaration.
Let me know if anything

Duplicate Dependency Error At Run Time

I added Parceler Dependency, in build.gradle.
dependencies {
// Parceler
compile 'org.parceler:parceler-api:1.0.4'
apt 'org.parceler:parceler:1.0.4'
}
When i build the project, the project builds successfully but at run time it's throwing the below error.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/parceler/Parceler$$Parcels$1.class
I tried ./gradlew clean command, i did invalidate and restart cache. I also update my android studio to 12.1 preview and gradle to 2.10, but still the same issue.
Any kind of help or suggestions would be appreciated.
It sounds like a duplication of classes between a library (or libraries) and the main project:
http://parceler.org/#avoiding_parcels_indexing
After going through the parceler.org doc, i solved this issue by setting parcelsIndex = false to each of the model classes.
Parceler will not write a Parceler$$Parcels mapping class if no indexable classes exist and the Parcels utiltiy class will fallback to looking up the generated class by name.

Categories

Resources