Run gradle
-q dependencies (or gradle
-q :projectName:dependencies) to generate a dependency report. You should see where r7 is
coming from, such as:
compile - Classpath for compiling the main sources.
+--- com.commonsware.cwac:camera-v9:0.5.4
| +--- com.actionbarsherlock:actionbarsherlock:4.4.0
| | \--- com.google.android:support-v4:r7
| +--- com.commonsware.cwac:camera:0.5.4
| \--- com.android.support:support-v4:18.0.+ -> 18.0.0
\--- com.android.support:support-v4:18.0.+ -> 18.0.0
Then, use the exclude directive
to block that dependency. In my case, it is coming from my CWAC-Camera library, and so I use:
module 的这样写 ~
dependencies {
compile('com.commonsware.cwac:camera-v9:0.5.4') {
exclude module: 'support-v4'
}
compile 'com.android.support:support-v4:18.0.+'
}

这篇博客详细介绍了如何解决在Android项目中遇到的'Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat'错误。作者提供了两种解决方案:一是检查并排除dependencies中的重复依赖,二是通过脚本排查所有module中的冲突依赖项,特别是v4库或其他引起冲突的库。


4414

被折叠的 条评论
为什么被折叠?



