我试图编译Leshan Server Demo作为Java库到Android的工作室,因为我想用它到一个应用程序。
当我编译它,我有它被包括限定特定类一个库,也由其他类中定义的,包括还有到项目中。这两个库是必要的。
这是我的gradle这个文件
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:{ “种”: “错误”, “文”: “节目类型已经存在:org.eclipse.leshan.server.cluster.RedisRegistrationStore”, “源”:[{}], “工具”: “D8” }
据我所知,这意味着两个库定义同一类:RedisRegistrationStore
我想要做的是排除以某种方式。
寻找不同的解决方案在这里找到,如Similar solution,我试图做一些例外,我已经修改了以这种方式gradle这个文件:
........
implementation 'org.eclipse.leshan:leshan-server-cluster:1.0.0-M10'{
exclude group: 'org.eclipse.leshan', module:'cluster'
}
........
但也许这意味着我不能做排除,因为我得到这个其他错误
在类型org.gradle.api.internal.artifacts.dsl的对象1.0.0-M10()为参数[build_cbo5jg18zhz8pvdsjliwvve5w $ _run_closure1 $ @ _closure2 428dc770]:找不到方法org.eclipse.leshan:乐山服务器集群。 dependencies.DefaultDependencyHandler。
顺便说一句,我不知道,一组/模块的排斥是正确的做法,以我的问题。我只需要删除一个类。
我也采取了看看这里:Android doc how to fix duplicate classes
但它不适合我的问题,因为我的类被声明到lib A和到lib B,而不是直接依赖的正式文件
你有一个想法如何在我的情况下进行,也许一般是什么来解决这个问题最好的办法?
而我在做什么错?
编辑
这是我的依赖关系树
+--- 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
尝试添加此行
implementation "com.android.support:design:${rootProject.ext.supportLibVersion}"
或者你也可以使用这个
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'