简体   繁体   English

Jar Lib在Android Project和Android APP上

[英]Jar Lib on Android Project And Android APP

I create a Jar Lib called "errors" in Java. 我在Java中创建了一个名为“错误”的Jar Lib。 I would like to use it in a module called "AndroidHTTPRequestLibrairy" and in my Android App. 我想在名为“ AndroidHTTPRequestLibrairy”的模块中以及在我的Android应用中使用它。

But i have a error : 但是我有一个错误:

Program type already present: 程序类型已经存在:

In my module (AndroidHTTPRequestLibrairy) build.gradle i have : 在我的模块(AndroidHTTPRequestLibrairy)build.gradle中,我有:

implementation files('libs/errors-0.1.3-SNAPSHOT.jar') 实施文件('libs / errors-0.1.3-SNAPSHOT.jar')

And in my app I have : 在我的应用程序中,我有:

implementation project(path: ':androidhttprequestlibrairy') 实施项目(路径:':androidhttprequestlibrairy')

and

implementation files('libs/errors-0.1.3-SNAPSHOT.jar') 实施文件('libs / errors-0.1.3-SNAPSHOT.jar')

I dont understand why. 我不明白为什么。

Can someone help me ? 有人能帮我吗 ?

Sincerely, 真诚的

This issue appears because of namespace conflict. 由于名称空间冲突而出现此问题。

You are trying to put one library twice in one project. 您试图将一个库两次放入一个项目中。 When the Gradle build your project and at the moment when it tries to put in your app.apk archive the errors-0.1.3-SNAPSHOT.jar library it finds out that there is already the errors-0.1.3-SNAPSHOT.jar library and throws an exception. 当Gradle构建项目并尝试将其放入app.apk存档时,会发现errors-0.1.3-SNAPSHOT.jar库,它发现已经存在error-0.1.3-SNAPSHOT.jar库并引发异常。

So the solutions is to remove the implementation files('libs/errors-0.1.3-SNAPSHOT.jar') dependency form the application build.gradle file, because it allready transited in the implementation project(path: ':androidhttprequestlibrairy') dependency 所以解决方案是从应用程序build.gradle文件中删除implementation files('libs/errors-0.1.3-SNAPSHOT.jar')依赖关系,因为它已经在implementation project(path: ':androidhttprequestlibrairy')依赖关系中进行了implementation project(path: ':androidhttprequestlibrairy')

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

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