如何仅使用一个库(多个相同的库) [英] How to use only one library (are multiple same ones)

查看:95
本文介绍了如何仅使用一个库(多个相同的库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

情况是,我在项目中使用库A.我还导入了本身也具有库A的外部库.因此,可以假定,当我尝试编译时,我收到多个DEX文件,定义错误,这意味着是重复项.

Situation is that I in my project use library A. I also import external library which also has itself a library A. So as you can assume, when I try to compile, I receive Multiple DEX files define error which means that there are duplications.

但是,如果我从项目中删除我的库,则无法使用其提供的方法.而且我找不到如何从模块中删除该库.

However, If I remove my library from the project, I cannot use its provided methods. And I cannot find how can I remove that library from the module.

有什么建议吗?

推荐答案

谢谢大家的建议. 我不想按照Michael的建议去做,因为我认为它是没有用的(具有多个用途相同的库)(已经知道这个技巧). 我已经尝试了ЯдмЖцмдшдт答案,但无法成功完全编译代码.我收到各种错误.

Thank you guys for your suggestions. I didn't want to do as Michael suggested because I believe it is kind of useless (having multiple libraries with same purpose) (already knew this trick). I have tried Ядм Жцмдшдт answer, but couldn't succeed in compiling code completely. I have received various errors.

最后,我解决了自己的问题.我做了什么:

In the end I have solved my own issue. What I did:

从我的主应用程序li​​bs文件夹中删除库.删除Android Studio中的依赖项(如果有)(文件->项目结构->依赖项(在模块应用程序中)->删除有关库的任何依赖项. 在Android Studio中清理项目(构建->清理项目). 转到我的库A所在的模块.转到该模块的build.gradle文件,并在依赖项群集中添加以下行

Remove library from my main app libs folder. Remove dependancies if any in Android Studio (File -> Project Structure -> Dependencies (On module app) -> remove if any regarding your library. Clean project in Android Studio (Build -> Clean Project). Go to the module where my library A is. Go to that module build.gradle file and add following line in the dependencies cluster

编译文件('libs/libraryA.jar')

compile files('libs/libraryA.jar')

同步代码并享受结果.

TLDR 我没有在外部模块中编译libraryA,但是这使我产生了重复错误,这就是我感到困惑的地方.通过将其从主项目中删除并将其添加到模块的编译列表中,可以解决此问题.

TLDR I didn't have libraryA compiled in my external module but it threw me duplication error, that's where I was confused. By removing it from my main project and adding it to my module's compilations list solved the problem.

这篇关于如何仅使用一个库(多个相同的库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆