gradle-lint-plugin icon indicating copy to clipboard operation
gradle-lint-plugin copied to clipboard

Resolving configuration 'implementation' directly is not allowed in an Android project

Open MaksimDmitriev opened this issue 7 years ago • 2 comments

I added the Gradle Lint plugin to my Android project in order to detect unused Gradle dependencies automatically. In my project there is a dependency whose classes are not used in the project:

implementation "com.google.android.gms:play-services-identity:15.0.1"

However, when I run ./gradlew lint from the command line, the Android SDK lint tools works (see BUILD SUCCESSFUL, the first line of the log below), and the Nebula plugin doesn't. What I see is:

BUILD SUCCESSFUL in 16s 32 actionable tasks: 31 executed, 1 up-to-date Error from [com.netflix.nebula.lint.rule.GradleLintRule$1] processing source file [null]

FAILURE: Build failed with an exception.

  • What went wrong: Resolving configuration 'implementation' directly is not allowed

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 16s 32 actionable tasks: 31 executed, 1 up-to-date Error from [com.netflix.nebula.lint.rule.GradleLintRule$1] processing source file [null]

FAILURE: Build failed with an exception.

  • What went wrong: Failed to notify build listener.

Resolving configuration 'implementation' directly is not allowed java.lang.IllegalStateException (no error message)

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

MaksimDmitriev avatar Jun 05 '18 12:06 MaksimDmitriev

Thank you for the bug report.

This should be fixed in version 9.3.4.

Can you give it a try @MaksimDmitriev?

OdysseusLives avatar Jul 02 '18 16:07 OdysseusLives

@OdysseusLives I checked out version 9.3.4. There's no "'implementation' directly is not allowed" error anymore. However, it looks like the Gradle Lint plugin doesn't remove unused code or warn about it.

You could build and compare three release APKs from my three Git branches:

  1. master - the Gradle Lint plugin is enabled, and minifyEnabled and shrinkResources are disabled.
  2. no-gradle-lint-plugin - the Gradle Lint plugin is disabled. minifyEnabled and shrinkResources are disabled as well.
  3. minify-enabled-shrink-res - the Gradle Lint plugin is disabled. minifyEnabled and shrinkResources are enabled.

The APKs from 1 and 2 are identical. I used the Android Studio APK Analyzer to compare them. An APK from 3 is approximately 1MB less in size (done by minifyEnabled and shrinkResources). So it looks like the Gradle Lint plugin didn't remove any code, or I misused it.

MaksimDmitriev avatar Jul 07 '18 12:07 MaksimDmitriev