简体   繁体   中英

How to exclude .jar dependency in Gradle

I build a project which consists of some other projects. In first project I have next dependency:

compile files('libs/google-play-services.jar')

Which is old version of Google services API. In other project I use other the latest Google API

compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.google.android.gms:play-services-maps:8.3.0'
compile 'com.google.android.gms:play-services-location:8.3.0'

As a result if I try to compile this projects as one, I get error about library conflict. Tell me please, how can I solve this problem?

The problem is that I get next conflict when launching built app:

error: cannot find symbol method getMapAsync(<anonymous OnMapReadyCallback>)

It seems that when compilation finishes and app launches, for unknown reasons it tries to take old api (where api should be version 8.3.0) instead of new.

It depends what the conflict is, but this is how you exclude dependencies:

compile ('com.google.android.gms:play-services-ads:8.3.0'){
    exclude module: 'support-annotations'
}

(a made up example)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM