首页 > Gradle中添加apache ftpserver依赖后无法编译通过

Gradle中添加apache ftpserver依赖后无法编译通过

环境为Android Studio(即使用Gradle自动构建),添加依赖ftpserver:

compile 'com.android.support:appcompat-v7:19.+'
compile('org.apache.ftpserver:ftpserver-core:1.0.6') {
//  exclude module: 'ftplet-api'
    exclude module: 'slf4j-api'
}
compile 'org.slf4j:slf4j-android:1.7.7'

此时编译不通过(在:app:dexDebug那一步出错):

com.android.dex.DexException: Multiple dex files define Lorg/apache/ftpserver/ftplet/Authentication;

根据提示来看,是因为ftpserver-core-1.0.6.jarftplet-api-1.0.6.jar均包含了org.apache.ftpserver.ftplet.Authentication类,造成构建失败。
有什么比较好的解决方案么?


加上exclude module: 'ftplet-api'当然也可以解决问题,但是觉得不太优雅。
另外,1.0.4是没有问题的,1.0.51.0.6有此问题。


tips:
要在build.gradle中添加如下语句,以避免文件冲突:

packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE'
}
【热门文章】
【热门文章】