环境为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.jar
和ftplet-api-1.0.6.jar
均包含了org.apache.ftpserver.ftplet.Authentication
类,造成构建失败。
有什么比较好的解决方案么?
加上exclude module: 'ftplet-api'
当然也可以解决问题,但是觉得不太优雅。
另外,1.0.4
是没有问题的,1.0.5
和1.0.6
有此问题。
tips:
要在build.gradle
中添加如下语句,以避免文件冲突:
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}