Questions tagged [gradle]

Gradle is a project build automation tool that uses a Groovy DSL. Gradle build scripts support Maven and Ivy repositories as well as plain file system for dependency management.

Gradle is a build automation tool focused on flexibility and performance. Gradle build scripts are written using a or DSL. Gradle allows the use of , , or user-defined repositories for dependency management.

Why Gradle?

  • Polyglot Builds: build in 60 different programming languages
  • Tool Integration: like , , , etc.
  • Robust Dependency Management
  • Powerful Yet Concise Logic: declarative and imperative
  • High Performance Builds
  • Build Reporting

Gradle allows you to describe the automation of a project build both declaratively and imperatively as you have the full power of the programming language to describe Gradle tasks.

There are many plugins for Gradle. Both native ones like the "War" plugin and third-party ones. These can be found at plugins.gradle.org

Latest Version: 7.6 (Nov 25, 2022)

The default name for the build script is build.gradle

Expressing a project dependency

repositories {
    mavenCentral()
}

dependencies {
    testCompile 'junit:junit:4.12'
}

Defining a task

Using a closure in defining a task count action:

task count {
    doFirst {
        4.times { print "$it " }
    }
}

Output of running gradle -q count:

> gradle -q count
0 1 2 3

Links:

Related tags:

Tips:

51043 questions
300
votes
9 answers

Warning "Kotlin plugin version is not the same as library version" (but it is!)

I have an Android studio project in which I have added a Java library module, which I call core. My three Gradle build files look like this. project/build.gradle buildscript { ext.kotlin_version = '1.2.40' repositories { google() …
Leo Aso
  • 11,898
  • 3
  • 25
  • 46
299
votes
32 answers

Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0

I've got a gradle FAILURE: ..."Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0." Case description: Attached to the project codebase the next libs: APP/build.gradle //(Required) Writing and executing…
Philipp Buhaievskiy
  • 3,217
  • 2
  • 10
  • 17
291
votes
18 answers

How do I activate a Spring Boot profile when running from IntelliJ?

I have 5 environments: - local (my development machine) - dev - qc - uat - live - staging I want different application properties to be used for each environment, so I have the following properties files each which have a different URL for…
dleerob
  • 4,951
  • 4
  • 24
  • 36
287
votes
27 answers

Could not find or load main class org.gradle.wrapper.GradleWrapperMain

I cleaned the whole project by deleting local directories like ~/.gradle, ~/.m2 ~./android and ~/workspace/project/.gradle and chosing File -> Invalidate Caches / Restart... in Android Studio. Now execution of the command ./gradlew leads to the…
SePröbläm
  • 5,142
  • 6
  • 31
  • 45
277
votes
8 answers

Gradle tasks are not showing in the gradle tool window in Android Studio 4.2

I just updated Android Studio to version 4.2. I was surprised to not see the Gradle tasks in my project. In the previous version, 4.1.3, I could see the tasks as shown here: But now I only see the dependencies in version 4.2: I tried to clear…
LeMimit
  • 6,524
  • 3
  • 12
  • 14
277
votes
28 answers

':app:lintVitalRelease' error when generating signed apk

I've tried to upload my apk on google play and encountered an error message: "You uploaded a debuggable APK. For security reasons you need to disable debugging before it can be published in Google Play. Learn more about debuggable APKs." Then I…
user3716366
  • 2,781
  • 2
  • 12
  • 5
276
votes
11 answers

How to check if Gradle dependency has new version?

In Android Studio when I use a + in the version number like: com.android.support:recyclerview-v7:21.+ I get a "Avoid using + in version numbers" warning. But when I use a specific version number I can't always use the latest version. I have a lot of…
osrl
  • 8,168
  • 8
  • 36
  • 57
275
votes
15 answers

Android Gradle Apache HttpClient does not exist?

I am trying to convert an IntelliJ project to the Gradle system of Android Studio but I am running into errors with Apache HttpClient? Am I missing something, the errors I am getting are as follows: Error:(10, 30) error: package…
Apqu
  • 4,880
  • 8
  • 42
  • 68
275
votes
24 answers

Android Studio gradle takes too long to build

My Android Studio project used to build faster but now it takes a long time to build. Any ideas what could be causing the delays? I have tried https://stackoverflow.com/a/27171878/391401 but no effect. I haven't any Anti virus running which could…
AndroidDev
  • 5,193
  • 5
  • 37
  • 68
270
votes
53 answers

A failure occurred while executing com.android.build.gradle.internal.tasks

I am getting this error while I am building APK. Cause 1: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade at…
apurv thakkar
  • 8,608
  • 3
  • 14
  • 19
258
votes
17 answers

Android Studio - no debuggable applications

I tried to debug a release version of my Android application but Android Studio failed to attach a debugger. (It could not find Android procces of my running application). Under devices console, there was only a message: No debuggable applications
Ondřej Z
  • 5,094
  • 3
  • 24
  • 30
253
votes
39 answers

Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details

Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details build:gradle(Module:app) buildscript { repositories { maven { url 'https://jitpack.io' url…
Ankur_009
  • 3,823
  • 4
  • 31
  • 47
253
votes
28 answers

"Gradle Version 2.10 is required." Error

As I've been using classpath 'com.android.tools.build:gradle:+' In the build.gradle file, I got the following error since gradle version 2.10 has been released. The error is : Warning:Gradle version 2.10 is required. Current version is 2.8. If …
252
votes
10 answers

How/When to generate Gradle wrapper files?

I am trying to understand how the Gradle Wrapper works. In many source repos, I see the following structure: projectRoot/ src/ build.gradle gradle.properties settings.gradle gradlew gradlew.bat gradle/ wrapper/ …
smeeb
  • 27,777
  • 57
  • 250
  • 447
250
votes
8 answers

How can I resolve the error "The minCompileSdk (31) specified in a dependency's AAR metadata" in native Java or Kotlin?

The error message: The minCompileSdk (31) specified in a dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) is greater than this module's compileSdkVersion (android-30).…
Mohammad Zeeshan
  • 4,525
  • 4
  • 12
  • 15