我正在尝试在我的项目中使用 OpenCSV 库,但出现此错误 - 我已经尝试删除该库并重新安装它,但错误仍然存在。
这是来自build.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile files('libs/opencsv.jar')}
最佳答案
我很好奇你为什么有自己的opencsv.jar?是因为您进行了自定义,还是因为防火墙问题,您只能在编译期间访问内部 Maven 存储库?
如果是这样,Prathmesh 就一针见血了,因为您必须自己引入所有传递依赖项。最新版本的依赖可以在opencsv sourceforge page找到.目前 opencsv 依赖于 commons-lang3 和 commons-beanutils。
否则只需将“编译文件”行更改为编译“com.opencsv:opencsv:3.9”,然后让 gradle 为您获取所有传递依赖项。
关于java.lang.NoClassDefFoundError : org. apache.commons.lang3.StringUtils,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43852806/