uiwjs / react-native-alipay

基于 React Native 的宝支付包,已更新到最新的支付宝 SDK 版本,支持Android/iOS。
https://uiwjs.github.io/react-native-alipay/
MIT License
208 stars 49 forks source link

在集成 react-native-wechat-lib 之后,Android 编译报错:Program type already present: com.alipay.a.a.e #29

Closed Riant closed 3 years ago

Riant commented 3 years ago

集成 react-native-wechat-lib 之前没有问题,但是之后,Android 编译就报错了:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDexDebug'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
     Program type already present: com.alipay.a.a.e
     Learn how to resolve the issue at https://developer.android.com/studio/build/dependencies#duplicate_classes.

看了下 alipay 的 sdk jar 文件里边确实有 com.alipay.a.a.e 这个类,请问下,是什么原因,有什么办法解决吗? 谢谢。

asagcs commented 3 years ago

同问++1 解决了么 @Riant

Leo2018Wu commented 3 years ago

同问++1 解决了么 @Riant

加问

Leo2018Wu commented 3 years ago

把libs文件夹里面的sdk替换成兼容版的不报错 image

Riant commented 3 years ago

@asagcs @Leo2018Wu
我之前以为 alipay 不会自定 linking, 所以作了手动 linking, 然后可能与其他手动 linking 的库冲突了,我当时是通过调整 android/app/build.gradle 里边的几个 implementation 的顺序解决的。

我现在移除了 alipay 的手动 linking 代码了,没出现这个问题了。当然,我还有一些库是不支持 auto linking 的,需要手动 linking, 也还是遇到了类似的问题,只不过冲突的是其他 class 而已,依然是通过调整 implementation 的顺序解决的。

注意在调整顺序之后,删除 build 文件夹里边的 generated 和 intermediates 2个文件夹再尝试编译。