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
246
votes
15 answers

Error:Conflict with dependency 'com.google.code.findbugs:jsr305'

I created a new project in Android Studio 2.2 Preview 1 with Android App and Backend module with Google Messaging. This is the app file: apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" …
245
votes
30 answers

How to set gradle home while importing existing project in Android studio

How to set gradle home while importing existing project in Android studio. While trying to import I need to set up this path.
Deniz
  • 12,332
  • 10
  • 44
  • 62
243
votes
11 answers

Android Studio how to run gradle sync manually?

I'm debugging Gradle issues in Android Studio and see references to "Run gradle sync", but I'm not sure how to run this command. How do I run "Gradle sync" from Android studio or Mac terminal?
Alex Stone
  • 46,408
  • 55
  • 231
  • 407
240
votes
7 answers

Android Studio 3.0 Flavor Dimension Issue

Upgraded to Studio Canary build. My previous project of Telegram Messenger is giving following error. Error:All flavors must now belong to a named flavor dimension. The flavor 'armv7' is not assigned to a flavor dimension. Learn more at…
Omkar Nath Singh
  • 3,375
  • 2
  • 15
  • 34
240
votes
5 answers

Install / upgrade gradle on Mac OS X

How do I install/upgrade gradle for Mac?
mllm
  • 17,068
  • 15
  • 53
  • 64
236
votes
38 answers

Cannot resolve symbol 'AppCompatActivity'

I've just tried to use Android Studio. I've created blank project and tried to create Activity which extends AppCompatActivity. Unfortunalty Android Studio "says" that it Cannot resolve symbol 'AppCompatActivity' I have compile…
234
votes
13 answers

How to determine the version of Gradle?

How can I know which version of Gradle I am using in my Android Studio? Please guide. I want to make sure I am using Gradle version 2.2.1.
user379888
234
votes
18 answers

Android Studio Stuck at Gradle Download on create new project

I have installed the new Android Studio. Everything was working fine but when I try to create a new project it gets stuck at downloading Gradle. Is there any way to install the Gradle required by Android Studio manually? Or any other method to solve…
Vipul Purohit
  • 9,807
  • 6
  • 53
  • 76
233
votes
20 answers

Error message "gradlew: command not found"

I am working on a Java project with Gradle Wrapper (gradlew). I use Ubuntu Linux as my OS. When I run "gradle" it runs, and gives me information. But when I run "gradlew", it outputs as: No command 'gradlew' found, did you mean: Command 'gradle'…
Hayden
  • 2,433
  • 2
  • 9
  • 9
233
votes
36 answers

It is currently in use by another Gradle instance

I want to do some basic functions. I'm running/building it in command line. I am referring User guide. And, doing some simple tasks. When I start to run simple tasks, it was build successfully. But, After some times, it is showing "It is currently…
Dhasneem
  • 4,037
  • 4
  • 33
  • 47
231
votes
16 answers

The number of method references in a .dex file cannot exceed 64k API 17

I am building an app with SugarORM Library but when I try to build the project for API 17 (didn't check for others) it shows build error. Information:Gradle tasks [:app:assembleDebug] :app:preBuild UP-TO-DATE :app:preDebugBuild…
228
votes
17 answers

unrecognized Attribute name MODULE (class com.sun.tools.javac.util.SharedNameTable$NameImpl)

I received this build error having updated my native android project to Android S (Pre release of android 12). Googling for the error threw up no valuable hits. One hit from Netbeans a few years back and some Xamarin problems. The stack trace is…
Chris
  • 4,662
  • 2
  • 19
  • 27
226
votes
29 answers

Gradle: Could not determine java version from '11.0.2'

I ran the following comment: ./gradlew app:installDebug only to be met with the log: FAILURE: Build failed with an exception. * What went wrong: Could not determine java version from '11.0.2'. * Try: Run with --stacktrace option to get the stack…
lesley2958
  • 2,538
  • 4
  • 15
  • 15
224
votes
12 answers

Could not find com.google.android.gms:play-services:3.1.59 3.2.25 4.0.30 4.1.32 4.2.40 4.2.42 4.3.23 4.4.52 5.0.77 5.0.89 5.2.08 6.1.11 6.1.71 6.5.87

referencing the play-services via gradle stopped working for me - boiled it down - even the sample I used as a reference in the first place stopped working: https://plus.google.com/+AndroidDevelopers/posts/4Yhpn6p9icf FAILURE: Build failed with an…
ligi
  • 39,001
  • 44
  • 144
  • 244
224
votes
2 answers

Gradle buildscript dependencies

What is the difference between declaring repositories in the buildscript section of the gradle build or in the root level of the build. buildscript { repositories { mavenCentral(); } } versus repositories { mavenCentral(); }
Jeff Storey
  • 56,312
  • 72
  • 233
  • 406