Nicolas
Nicolas

Reputation: 7081

Library not adding its dependencies when used

I made a library, but when I tried to use it with implementation 'com.example:mylibrary:1.3.0' in my app's build.gradle, I keep getting an error saying the ConstraintLayout dependency (which the library uses but not the app) is not found. However it was explicitly defined in the library's build.gradle with implementation.

When I ran gradlew app:dependencies on the terminal, it shows that the library has no dependencies, even though it actually has 2. This seems to be the source of the problem, Gradle can't detect the dependencies of the library.

I didn't run into this problem for a while but when I decided to remove the ConstraintLayout dependency from my app an error appears during build.

Upvotes: 0

Views: 718

Answers (1)

ישו אוהב אותך
ישו אוהב אותך

Reputation: 29783

When you're using implementation for the dependencies in your library, the project which is dependent with it will not see the dependencies. You need to use api instead of implementation.

Upvotes: 1

Related Questions