0

It would be easier for me to show you but the long story short.

  1. Main Application
  2. Created a Library lets call it SECOND
  3. Created a Shopping List Library call it THIRD

When I add my THIRD dependency to my SECOND library when using implementation in the gradle file, I am not able to implement interfaces for some reason. When using api it works just fine.

Also, we are adding this by importing the aar and pom file manually.

Project Level Gradle For SECOND

allprojects {
    repositories {
        google()
        jcenter()
        maven { url "$projectDir/../THIRD" }
    }

}

Only way to actually allow access to the interfaces is to use API api('com.THIRD.@aar')

Tim
  • 41,901
  • 18
  • 127
  • 145
Kyle Wolff
  • 141
  • 2
  • 10
  • *When using api it works just fine* any reason you don't want to use `api`? Not sure what the issue is here – Tim Feb 25 '19 at 16:17

1 Answers1

1

This is quite as expected: declarations from implementation dependencies of a library are not visible during compilation of the library usages and are only available at runtime.

On contrary, api dependencies are visible during compilation of the library usages, too.

You should only use the implementation configuration if you don't want the library users to see the declaration from a dependency, which is certainly not the case if you expect the user to implement an interface from the dependency.

See: Gradle dependency configuration: implementation vs api vs runtimeonly vs compileonly

hotkey
  • 140,743
  • 39
  • 371
  • 326