報錯:
Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
在Android Studio裏build項目時不會報錯,但是run項目的時候就會報上面的那個錯誤
當Module裏 添加的依賴和app.build.guild裏添加的依賴重複時就會報錯
一、解決方案
compile('com.mxn.soul:flowingdrawer-core:1.2.0')
compile('com.rengwuxian.materialedittext:library:2.1.4') {
exclude group: 'com.nineoldandroids'
}
flowingdrawer-core這個依賴裏的libs文件夾下有nineoldandroids2.4.0.jar這個jar包。
materialedittext這個依賴裏的gradle裏compile ‘com.nineoldandroids.library:2.4.0’
所以會導致重複引用了jar包。在materialedittext的依賴裏添加語句 exclude group: ‘com.nineoldandroids’,意思是編譯的時候將group爲com.nineoldandroids的所有library都去除在外,這樣materialedittext就會自動去引用flowingdrawer-core項目裏的nineoldandroids2.4.0.jar包了。
不過,我又進行了其他的嘗試,我改成如下配置
compile('com.mxn.soul:flowingdrawer-core:1.2.0'){
exclude group: 'com.nineoldandroids'
}
compile('com.rengwuxian.materialedittext:library:2.1.4')
這樣還是會出問題。想了想,應該是exclude語句只能在編譯時將gradle文件裏的依賴去除掉,而不能去掉libs文件裏的jar包引用。