I am building an Expo app using eas which makes use of the react-native-usb-serialport library. When building this library I get the following error:
[stderr]
* What went wrong:
[stderr]
Execution failed for task ':app:checkDebugDuplicateClasses'.
[stderr]
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
[stderr]
> Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-20.0 (com.google.guava:guava:20.0) and jetified-listenablefuture-1.0 (com.google.guava:listenablefuture:1.0)
[stderr]
From what I understand, this is a known issue that can be fixed by editing the android/app/bundle.gradle
in a standard java Android app. However because I am building with eas/Expo, I do not think that there is a way to do this directly. I forked the react-native-usb-serialport
library and tried removing the guava dependency from the library's gradle file as suggested here, but then the library failed to build because the dependency was missing. I also tried upgrading the library's guava dependency to version 27.0, but when I did this I got a different build issue saying that guava 27.0 could not be found.
What else could I try?
I fixed the problem by forking the
react-native-serial-usb
library and removing the dependency on Guava. Only one function from Guava was used in the library so this was easy.https://github.com/lr210/react-native-usb-serialport/tree/master/android