我在试着编译
Leshan Server Demo
因为我想把它用在一个应用程序中。
当我编译它的时候,我有一个库,它定义了一个特定的类,这个类也由另一个类定义,也包括在项目中。两个库都是必需的。
这是我的档案
apply plugin: 'java-library'
sourceCompatibility = "8"
targetCompatibility = "8"
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'org.slf4j:slf4j-android:1.7.25'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
implementation 'org.jmdns:jmdns:3.5.5'
implementation 'commons-cli:commons-cli:1.4'
implementation 'org.eclipse.californium:californium-core:2.0.0-M13'
implementation 'org.eclipse.jetty:jetty-webapp:9.4.14.v20181114'
implementation 'org.eclipse.jetty:jetty-continuation:9.4.14.v20181114'
implementation 'commons-io:commons-io:2.6'
implementation 'org.apache.commons:commons-lang3:3.8.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.eclipse.leshan:leshan-server-cf:1.0.0-M10'
implementation 'org.eclipse.leshan:leshan-server-cluster:1.0.0-M10'
}
这些源当前与github存储库中的文件相同(链接在上面)
如果我试图编译,我有:
任务:应用程序:transformDexArchiveWithExternalLibsDexMergerForDebug失败
AGPBI:{“kind”:“error”,“text”:“程序类型已经存在:org.eclipse.leshan网站.server.cluster.RedistrationsStore“,“源”:[{}],“工具”:“D8”}
据我所知,这意味着两个库定义了同一个类:redistrationstore
我想做的是以某种方式排除它。
寻找不同的解决方案,如
Similar solution
........
implementation 'org.eclipse.leshan:leshan-server-cluster:1.0.0-M10'{
exclude group: 'org.eclipse.leshan', module:'cluster'
}
........
但也许这意味着我不能排除,因为我得到了另一个错误
找不到方法org.eclipse.leshan网站:乐山服务器-集群:1.0.0-M10()用于参数[建造\u cbo5jg18zhz8pvdsjliwvve5w$_run_closure1$_closure2@428dc770]类型对象上网址:org.gradle.api.内部.artifacts.dsl.dependencies.DefaultDependencyHandler.
我也看了一下这里:
Android doc how to fix duplicate classes
但它不适合我的问题,因为我的类被声明为liba和libb,而不像官方文档中那样直接依赖
你知道如何处理我的案子吗?也许总的来说,解决这个问题的最佳方法是什么?
我做错什么了?
编辑
这是我的依赖关系树
+--- org.slf4j:slf4j-android:1.7.25
| \--- org.slf4j:slf4j-api:1.7.25
+--- com.fasterxml.jackson.core:jackson-databind:2.9.8
| +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
| \--- com.fasterxml.jackson.core:jackson-core:2.9.8
+--- org.jmdns:jmdns:3.5.5
| \--- org.slf4j:slf4j-api:1.7.25
+--- commons-cli:commons-cli:1.4
+--- org.eclipse.californium:californium-core:2.0.0-M13
| +--- org.eclipse.californium:californium-legal:2.0.0-M13
| +--- org.eclipse.californium:element-connector:2.0.0-M13
| | +--- org.eclipse.californium:californium-legal:2.0.0-M13
| | \--- org.slf4j:slf4j-api:1.7.25
| \--- org.slf4j:slf4j-api:1.7.25
+--- org.eclipse.jetty:jetty-webapp:9.4.14.v20181114
| +--- org.eclipse.jetty:jetty-xml:9.4.14.v20181114
| | \--- org.eclipse.jetty:jetty-util:9.4.14.v20181114
| \--- org.eclipse.jetty:jetty-servlet:9.4.14.v20181114
| \--- org.eclipse.jetty:jetty-security:9.4.14.v20181114
| \--- org.eclipse.jetty:jetty-server:9.4.14.v20181114
| +--- javax.servlet:javax.servlet-api:3.1.0
| +--- org.eclipse.jetty:jetty-http:9.4.14.v20181114
| | +--- org.eclipse.jetty:jetty-util:9.4.14.v20181114
| | \--- org.eclipse.jetty:jetty-io:9.4.14.v20181114
| | \--- org.eclipse.jetty:jetty-util:9.4.14.v20181114
| \--- org.eclipse.jetty:jetty-io:9.4.14.v20181114 (*)
+--- org.eclipse.jetty:jetty-continuation:9.4.14.v20181114
+--- commons-io:commons-io:2.6
+--- org.apache.commons:commons-lang3:3.8.1
+--- com.google.code.gson:gson:2.8.5
+--- org.eclipse.leshan:leshan-server-cf:1.0.0-M10
| +--- org.eclipse.leshan:leshan-core-cf:1.0.0-M10
| | +--- org.eclipse.leshan:leshan-core:1.0.0-M10
| | | +--- org.slf4j:slf4j-api:1.7.25
| | | \--- com.eclipsesource.minimal-json:minimal-json:0.9.5
| | +--- org.eclipse.californium:californium-core:2.0.0-M12 -> 2.0.0-M13 (*)
| | \--- org.eclipse.californium:scandium:2.0.0-M12
| | +--- org.eclipse.californium:element-connector:2.0.0-M12 -> 2.0.0-M13 (*)
| | \--- org.slf4j:slf4j-api:1.7.25
| +--- org.eclipse.leshan:leshan-server-core:1.0.0-M10
| | \--- org.eclipse.leshan:leshan-core:1.0.0-M10 (*)
| +--- org.eclipse.californium:californium-core:2.0.0-M12 -> 2.0.0-M13 (*)
| \--- org.eclipse.californium:scandium:2.0.0-M12 (*)
\--- org.eclipse.leshan:leshan-server-cluster:1.0.0-M10
+--- org.eclipse.leshan:leshan-core:1.0.0-M10 (*)
+--- org.eclipse.leshan:leshan-server-cf:1.0.0-M10 (*)
+--- redis.clients:jedis:2.8.0
| \--- org.apache.commons:commons-pool2:2.3
+--- com.eclipsesource.minimal-json:minimal-json:0.9.5
+--- commons-cli:commons-cli:1.3.1 -> 1.4
\--- ch.qos.logback:logback-classic:1.2.3
+--- ch.qos.logback:logback-core:1.2.3
\--- org.slf4j:slf4j-api:1.7.25