facebook / redex

A bytecode optimizer for Android apps
https://fbredex.com/
MIT License
6.03k stars 653 forks source link

RedexError: 4 with message:Found duplicate class in two different files #597

Closed excitedhaha closed 3 years ago

excitedhaha commented 3 years ago

Redex failed with error: libc++abi.dylib: terminating with uncaught exception of type RedexException: RedexError: 4 with message: Found duplicate class in two different files. with extra info: ("class", "Landroid/view/View$OnGenericMotionListener;") ("dex", "/var/folders/8g/hhwx3zb903l2dxpzpd1t2q980000gn/T/tmpgeb5bggw.redex_dexen/dex0/classes.dex") ("jar", "/Users/didi/Library/Android/sdk/platforms/android-30/android.jar")

I removed the View class using a Gradle transform, and I checked the output dex, it's deleted. But the error still occurred.

excitedhaha commented 3 years ago

For Information https://github.com/facebook/redex/issues/586#event-4372760616

wsanville commented 3 years ago

Are you saying that Landroid/view/View$OnGenericMotionListener; doesn't actually exist in the file at /var/folders/8g/hhwx3zb903l2dxpzpd1t2q980000gn/T/tmpgeb5bggw.redex_dexen/dex0/classes.dex?

excitedhaha commented 3 years ago

Yes, I decompiled the dex using dex2jar

wsanville commented 3 years ago

I'm not familiar with dex2jar (which sounds like a third party tool). Can you run the dexdump tool (part of the Android SDK, should be in your build-tools folder somewhere) on that classes.dex file and share parts of that output, or at the very least check if it contains the class?

If the class is in there, there will be a line like:

Class descriptor : 'Landroid/view/View$OnGenericMotionListener;'

I.e. something like dexdump /var/folders/8g/hhwx3zb903l2dxpzpd1t2q980000gn/T/tmpgeb5bggw.redex_dexen/dex0/classes.dex | grep "Class desc.*Landroid/view/View[$]OnGenericMotionListener;" is what I'd run.

excitedhaha commented 3 years ago

The dexdump finds the class, it seems that I deleted the View class but not the inner classes. The problem resolved now, thank you.

shubhamguptadream11 commented 1 year ago

@excitedhaha How exactly are you deleting those duplicate files? I am also getting this but not able to figure out how to remove these.