Not able to copy implementation dependencies


(Gabriel Lundgren) #1

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?


(James Justinic) #2

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.


(Gabriel Lundgren) #4

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?


(Keith Hoopes) #5

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