1

I need to force the configuration in the gradle in my android application and my gradle verision is 3.0.1. the below is the old way of doing it and i need the equivalent of Gradle 3.0.

releaseCompile project(path: ':androidLibrary', configuration: 'debug')

My error version :

releaseImplementation project(path: ':androidLibrary', configuration: 'debug')

the above gives me an error message as

Error:Unable to resolve dependency for ':main@release/compileClasspath': Could not resolve project :androidLibrary."

Error:Unable to resolve dependency for ':main@releaseUnitTest/compileClasspath': Could not resolve project :androidLibrary.

Prabhakaran
  • 1,264
  • 2
  • 20
  • 47

1 Answers1

0

Have you tried the following instead?

implementation project(':androidLibrary')

According to Google's Migrate to Android Plugin for Gradle 3.0.0, "targeting a specific variant of a local module dependency (for example, using configuration: 'debug') causes the following build error:"

Error:Unable to resolve dependency for ':app@debug/compileClasspath':
  Could not resolve project :library.
Error:Unable to resolve dependency for ':app@release/compileClasspath':
  Could not resolve project :library.

I think you're targeting a specific variant of a local module dependency when you use the release prefix in releaseImplementation and when you include configuration: 'debug' in this statement:

releaseImplementation project(path: ':androidLibrary', configuration: 'debug')

It goes on to recommend the following solution:

"You should instead configure your dependencies as follows":

dependencies {
    // This is the old method and no longer works for local
    // library modules:
    // debugImplementation project(path: ':library', configuration: 'debug')
    // releaseImplementation project(path: ':library', configuration: 'release')

    // Instead, simply use the following to take advantage of
    // variant-aware dependency resolution. You can learn more about
    // the 'implementation' configuration in the section about
    // new dependency configurations.
    implementation project(':library')

    // You can, however, keep using variant-specific configurations when
    // targeting external dependencies. The following line adds 'app-magic'
    // as a dependency to only the "debug" version of your module.

    debugImplementation 'com.example.android:app-magic:12.3'
}

source: Migrate dependency configurations for local modules

Michael Osofsky
  • 11,429
  • 16
  • 68
  • 113
  • This don't address the question. He wants to force a `release` to depend on `debug` variant of `library`. I'm actually facing the same problem, and the auto variant-resolution feature will resolve to `release` intead of `debug`. – gmazzo Mar 17 '20 at 11:41