无法排除未使用的依赖项

时间:2017-11-02 08:39:47

标签: android build.gradle

我正在尝试从play-services-maps中排除支持注释,但似乎不起作用。我的相关依赖树粘贴在下面。请让我知道如何添加排除。

这就是我试图排除的方式。

compile ('com.google.android.gms:play-services-maps:9.6.1',
{
    exclude group: 'com.android.support', module: 'support-annotations'
})

这是树。

_releaseApk - ## Internal use, do not manually configure ##
+--- com.google.android.gms:play-services-maps:9.6.1
|    +--- com.google.android.gms:play-services-base:9.6.1
|    |    +--- com.google.android.gms:play-services-basement:9.6.1
|    |    |    \--- com.android.support:support-v4:24.0.0 -> 25.1.0
|    |    |         +--- com.android.support:support-compat:25.1.0
|    |    |         |    \--- com.android.support:support-annotations:25.1.0
|    |    |         +--- com.android.support:support-media-compat:25.1.0
|    |    |         |    +--- com.android.support:support-annotations:25.1.0
|    |    |         |    \--- com.android.support:support-compat:25.1.0 (*)
|    |    |         +--- com.android.support:support-core-utils:25.1.0
|    |    |         |    +--- com.android.support:support-annotations:25.1.0
|    |    |         |    \--- com.android.support:support-compat:25.1.0 (*)

添加了完整的依赖项列表

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.google.android.gms:play-services-maps:9.6.1'
    compile 'com.google.android.gms:play-services-location:9.6.1'
    compile 'com.google.code.gson:gson:2.8.0'
    compile 'commons-codec:commons-codec:1.8'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    compile 'com.android.support:preference-v7:25.1.0'
}

1 个答案:

答案 0 :(得分:1)

我认为你的语法错误。 它应该是这样的:

compile ('com.google.android.gms:play-services-maps:9.6.1')
{
    exclude group: 'com.android.support', module: 'support-annotations'
}