记一次Android智齿SDK导致BUG

Could not determine the dependencies of task ':app:preOnlineDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:onlineDebugRuntimeClasspath'.   > Could not find :unspecified:.     
    Searched in the following locations:       
    - file:/D:/xxxxxxx/xxxxxxx/libs/baseRes/libs/unspecified.jar     
    Required by:         
        project :app > project :modules:mainpage > com.sobot.chat:sobotsupport-glidev4:1.0.10 > com.sobot.chat:sobotsdk-imageloader:1.0.4 
Possible solution: - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
复制代码

编译报错信息如上,让人实在摸不着头脑。

问题复现:

由于C盘空间告警,所以删除了gradle的缓存目录,然后再编译项目就会报上面的错误,试过很多解决办法,都不见效,网上也没有搜索到类似问题的解决办法,非常玄乎兄弟~

问题分析:

可以看到问题最终指向的是这个SDK,解决办法就从这里入手!

com.sobot.chat:sobotsdk-imageloader:1.0.4
复制代码

SDK内部情况如下图,很简单,只有一个抽象类,那我们在引入智齿SDK的时候,把这个SDK排除掉,同时把这个类替换一下,不就OK了吗?NICE~

解决问题:

第一步:排除引入。

第二步:编写自己的 SobotImageLoader.java 类。实际上就是复制一份,注意保持包名类名的一致。

第三步:初始化(加载)这个类。其实这一步也可以不要,提前加载只是为了确保类在使用的时候被加载到虚拟里,保持代码健壮性。这里最好在 Application 里面操作。

总结:

通过测试,以上处理方式能解决这个奇葩BUG。这里记录一下,希望大家碰到类似问题能有个参考,同时也希望各位能有更好的解决方式,留言我们可以一起交流一下~

Guys,Peace & Love

猜你喜欢

转载自juejin.im/post/6955038931289276429