今天在用Android Studio时候,新建一个项目,平台会自动帮我引入
compile 'com.android.support:appcompat-v7:23.1.1'
并且导入了support-v4-23.1.1
包。
但是当我引入另外一个包时'org.eclipse.paho:org.eclipse.paho.android.service:1.0.2'
里面已经包含了
不太清楚support-v4-23.1.1
和support-v4-r7
有什么区别,但是肯定有重复的地方,因此想去掉support-v4-r7
依赖。
首先尝试在build.gradle中这样写,
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
exclude 'com.google.android:support-v4'
}
}
但是Android Studio直接不通过,竟然说Error:(28, 0) Gradle DSL method not found: 'compile()'
几经周折,终于找到了答案,
修改成
compile('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {
exclude(group: 'com.google.android', module: 'support-v4')
}
OK啦!