I've an weird behavior when using modules on gradle with Android Studio... it's kind complicated to explain so i think is better to give an example
Let say my application has two modules
:bar
:foo
foo
uses play-services-location
so I do import it on its build.gradle. foo
compiles fine.
bar
uses foo
, so on build.gradle
of bar's folder I do:
api project(path: ':foo')
bar
also uses play-services-location
but as bar
imports foo
i think it should transitivelly import play-services-location
however if I don't explicit do
implementation "com.google.android.gms:play-services-location:$location_library_version"
bar doesn't compile
So am I missing something? Shouldn't it automaticly import all the dependency dependencies... so any transitive dependency be ready and I didn't need to re-import it?
答案 0 :(得分:2)
You should use 'api' (not 'implemenatation') for 'google-play-location' in 'foo', so it can be depended by 'bar' which uses 'foo'. And if there is no other modules which depends on 'bar', it is better to specify 'implementation foo' in 'bar', not 'api'