question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot apply plugin into Android multi module project

See original GitHub issue

I cannot find a way to apply this plugin into my Android project. I tried both approaches:

plugins {
    id "org.jlleitschuh.gradle.ktlint" version "6.3.0"
}

and

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "gradle.plugin.org.jlleitschuh.gradle:ktlint-gradle:6.3.0"
  }
}

apply plugin: "org.jlleitschuh.gradle.ktlint"

Also I tried to apply it in multiple gradle files (root file and module files). I keep getting following error:

Unable to load class 'org.gradle.api.provider.SetProperty'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)</li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)</li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

Any of solutions proposed by error didn’t help in any way.

Gradle wrapper version is 4.4 and gradle plugin version is 3.0.1. I am willing to provide any further required information.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Tapchicomacommented, Nov 13, 2018

Ah, found the problem - https://docs.gradle.org/current/javadoc/org/gradle/api/provider/SetProperty.html - it is only available since Gradle 4.5

Possible solutions:

  • Update Android plugin to 3.2 and Gradle to 4.5 version
  • Use older ktlint-gradle version 5.1.0 - this should work in your setup

@JLLeitschuh I am tending not to fix this, but update minimal supported Gradle version. Also really need to do #148 that will run against lower supported and latest released Gradle versions to avoid such issues in the future.

0reactions
Tapchicomacommented, Nov 14, 2018

Interesting stacktrace, I don’t see anything related to ktlint-gradle.

In versions 6.x.x we removed usages of afterEvaluate {} and this line java.lang.ClassNotFoundException: com.android.ide.common.res2.ResourceSet related to android plugin itself.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Managing Android Multi-module Project with Gradle Plugin ...
In this post, I will introduce how we can make use of a custom Gradle plugin to help us manage Android project modules....
Read more >
How to properly add gradle plugin to multiproject?
The reason this works is explained by the Gradle docs: For multi-project builds, the dependencies declared with a project's buildscript() method ...
Read more >
Sharing Gradle Configuration in Multi-Module Android Projects
This post shows you a method of sharing common configuration between your Android Library modules in order to cut down on boilerplate Gradle...
Read more >
Developing Custom Gradle Plugins
When the plugin is applied to a project, Gradle creates an instance of the plugin class and calls the instance's Plugin.apply() method. The...
Read more >
Common modularization patterns - Android Developers
It's a central place to declare all your dependencies and is available to all the modules in a project. Use convention plugins to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found