简体   繁体   English

Gradle 从 aar 中排除类

[英]Gradle exclude classes from aar

Im using lib Gson in my dependecies and im import a.aar with some classes from Gson that are imported to a project.我在我的依赖项中使用 lib Gson 并导入 a.aar,其中包含一些来自 Gson 的类,这些类被导入到项目中。 When i build my project i keep getting duplicated classes, bcz its on my dependency and aar classes.当我构建我的项目时,我不断得到重复的类,bcz 它依赖于我的依赖项和 aar 类。

How i can exclude gson classes from aar?如何从 aar 中排除 gson 类?

I have been trying with:我一直在尝试:

  • exclude group: I think this is not work since is not a dependency from aar, but classes inside.排除组:我认为这是行不通的,因为它不是 aar 的依赖项,而是里面的类。
  • transitive true, same reason as before及物真,与以前相同的原因

Can i do it?我可以做吗? or should i get other.aar with gson as dependecy?或者我应该得到 other.aar 与 gson 作为依赖?

Usually.aar includes with.pom file which includes all dependency of "aar library" use.通常.aar 包含 with.pom 文件,其中包含“aar 库”使用的所有依赖项。

If you are creating own library and use it in another application follow refer the link below.如果您正在创建自己的库并在另一个应用程序中使用它,请参考下面的链接。 https://medium.com/swlh/android-library-kotlin-creation-access-deploy-problems-fixes-everything-you-want-to-c1a1701f0e8f https://medium.com/swlh/android-library-kotlin-creation-access-deploy-problems-fixes-everything-you-want-to-c1a1701f0e8f

Or或者

Try this following试试下面这个

implementation(name: '××××××× aar package', ext: 'aar') {
    exclude module: 'gson'
}

Let me know if this helpfull让我知道这是否有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM