Not able to copy implementation dependencies

After upgrading my Android project to use gradle plugin 3.0.1 for Android Studio and Gradle tool to 4.1., I switched the dependency configuration from ‘compile’ to ‘implementation’. Before upgrading versions, I used to copy ‘compile’ dependencies to a specific folder using this simple gradle task :

task copyLibs(type: Copy) {
from configurations.compile
into “$project.rootDir/reports/libs/”
}

Is there a way to copy ‘implementation’ dependencies to a specific folder with a gradle task?

You likely want to change from configurations.compile to configurations.compileClasspath for similar results. There are diagrams of the new configurations and how they’re wired with Java Library Plugin documentation. Ignore the API related configurations if you’re not using the java-library plugin. The other configurations are relevant.

I’ve changed it as you suggested, however 3 of my dependencies are sub-modules of my application and now I get the following error:

Could not determine the dependencies of task ‘:app:copyLibsFromApp’.

Could not resolve all task dependencies for configuration ‘:app:compileClasspath’.
Could not resolve project :foo.
Required by:
project :app
Cannot choose between the following configurations of project :foo:
- debugApiElements
- releaseApiElements
All of them match the consumer attributes:
- Configuration ‘debugApiElements’:
- Found com.android.build.api.attributes.BuildTypeAttr ‘debug’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr ‘Aar’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.VariantAttr ‘debug’ but wasn’t required.
- Required org.gradle.api.attributes.Usage ‘java-api’ and found compatible value ‘java-api’.
- Configuration ‘releaseApiElements’:
- Found com.android.build.api.attributes.BuildTypeAttr ‘release’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr ‘Aar’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.VariantAttr ‘release’ but wasn’t required.
- Required org.gradle.api.attributes.Usage ‘java-api’ and found compatible value ‘java-api’.
Could not resolve project :bar.
Required by:
project :app
Cannot choose between the following configurations of project :bar:
- debugApiElements
- releaseApiElements
All of them match the consumer attributes:
- Configuration ‘debugApiElements’:
- Found com.android.build.api.attributes.BuildTypeAttr ‘debug’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr ‘Aar’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.VariantAttr ‘debug’ but wasn’t required.
- Required org.gradle.api.attributes.Usage ‘java-api’ and found compatible value ‘java-api’.
- Configuration ‘releaseApiElements’:
- Found com.android.build.api.attributes.BuildTypeAttr ‘release’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr ‘Aar’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.VariantAttr ‘release’ but wasn’t required.
- Required org.gradle.api.attributes.Usage ‘java-api’ and found compatible value ‘java-api’.
Could not resolve project :log.
Required by:
project :app
Cannot choose between the following configurations of project :log:
- debugApiElements
- releaseApiElements
All of them match the consumer attributes:
- Configuration ‘debugApiElements’:
- Found com.android.build.api.attributes.BuildTypeAttr ‘debug’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr ‘Aar’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.VariantAttr ‘debug’ but wasn’t required.
- Required org.gradle.api.attributes.Usage ‘java-api’ and found compatible value ‘java-api’.
- Configuration ‘releaseApiElements’:
- Found com.android.build.api.attributes.BuildTypeAttr ‘release’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.AndroidTypeAttr ‘Aar’ but wasn’t required.
- Found com.android.build.gradle.internal.dependency.VariantAttr ‘release’ but wasn’t required.
- Required org.gradle.api.attributes.Usage ‘java-api’ and found compatible value ‘java-api’.

Any clues on why this is happening?

1 Like

Any updates to this issue? We have run into the same problem, now using Gradle “4.10”.