1***@qq.com
1***@qq.com
  • 发布:2024-05-20 10:54
  • 更新:2024-10-31 01:15
  • 阅读:361

uniapp原生插件自定义基座打包报错,okhttp冲突

分类:uni-app

报错提示:

* What went wrong:  
Execution failed for task ':app:checkReleaseDuplicateClasses'.  
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable  
> Duplicate class okhttp3.Address found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Authenticator found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Authenticator$Companion found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Authenticator$Companion$AuthenticatorNone found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Cache found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Cache$CacheResponseBody found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Cache$CacheResponseBody$1 found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Cache$Companion found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Cache$Entry found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Cache$Entry$Companion found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Cache$RealCacheRequest found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Cache$RealCacheRequest$1 found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)  
Duplicate class okhttp3.Cache$urls$1 found in modules jetified-okhttp-4.9.3 (com.squareup.okhttp3:okhttp:4.9.3) and jetified-okhttp-4.9.3.k6 (okhttp-4.9.3.k6.jar)

问题:
原生插件需要集成vpn登陆,vpn中依赖的是国密的okhttp的包【okhttp-4.9.3.k6.jar】,与uniapp框架自带的包冲突,请问这个该如何解决?

尝试1:
按照配置文件排除掉uniapp自带的okhttp依赖

"excludeDependencies": [  
    "okhttp-4.9.3.jar"  
]

结果:同样的报错,显然好像没有排除掉自带的jar包

尝试2:
按照配置文件排除掉uniapp自带的okhttp依赖

"excludeDependencies": [  
    "com.squareup.okhttp3:okhttp:4.9.3"  
]

结果:还是同样的报错,应该也没有排除掉自带的jar包

完整错误日志:https://app.liuyingyong.cn/build/errorLog/cd274a80-164e-11ef-9e3d-2b512949510c

2024-05-20 10:54 负责人:无 分享
已邀请:
izhangshumeng

izhangshumeng

请问解决了吗

屠苏

屠苏

找个答案真难

要回复问题请先登录注册