Questions tagged [build.gradle]

The file build.gradle describes in the Groovy language the default actions and tasks launched by the 'gradle' command in the appropriate folder.

Gradle can automate the building, testing, publishing, deployment and more of software packages or other types of projects such as generated static websites, generated documentation or indeed anything else.

Gradle combines the power and flexibility of Ant with the dependency management and conventions of Maven into a more effective way to build. Powered by a Groovy DSL and packed with innovation, Gradle provides a declarative way to describe all kinds of builds through sensible defaults. Gradle is quickly becoming the build system of choice for many open source projects, leading edge enterprises and legacy automation challenges.

Official Gradle website: https://gradle.org/

9056 questions
159
votes
17 answers

Autoincrement VersionCode with gradle extra properties

I'm building an Android app with gradle. Until now I used the Manifest file to increase the versionCode, but I would like to read the versionCode from an external file and depending if it is the release flavor or the debug flavor increase the…
carvaq
  • 1,816
  • 3
  • 16
  • 21
158
votes
19 answers

Cannot resolve symbol 'AndroidJUnit4'

Obviously I need the correct import statment to solve this problem. According to the docs for AndroidJUnit4, this should be import android.support.test.runner.AndroidJUnit4; When I do that, Android Studio highlights runner in red and complains…
155
votes
8 answers

How do I exclude all instances of a transitive dependency when using Gradle?

My gradle project uses the application plugin to build a jar file. As part of the runtime transitive dependencies, I end up pulling in org.slf4j:slf4j-log4j12. (It's referenced as a sub-transitive dependency in at least 5 or 6 other transitive…
Jens D
  • 4,229
  • 3
  • 16
  • 19
150
votes
5 answers

Could not find method leftShift() for arguments after updating studio 3.4

After updating studio 3.4 and Gradle version to 5.1.1 I got the error on my task as Could not find method leftShift() My task: task incrementBetaVersion << { println("Incrementing Beta Version Number...") …
Bhuvanesh BS
  • 13,474
  • 12
  • 40
  • 66
146
votes
12 answers

Installation failed with message Error: android.os.ParcelableException: java.io.IOException: Requested internal only, but not enough space

I was getting the message > Installation failed with message Failed to establish session. so following some responses to the problem I disabled Instant Run and I started getting > Installation failed with message Error:…
138
votes
10 answers

How do I read properties defined in local.properties in build.gradle

I have set sdk.dir and ndk.dir in local.properties. How do I read the values of sdk.dir and ndk.dir in the build.gradle file?
Vikram
  • 11,885
  • 5
  • 22
  • 16
136
votes
23 answers

Java finished with non-zero exit value 2 - Android Gradle

I'm getting this error executing my Android app (I cleaned it and then built it, but the error is still present) Sync: OK Make Project: OK Clean: OK Run: Error Error:Execution failed for task ':app:dexDebug'…
Maverick.pe
  • 1,917
  • 4
  • 15
  • 20
135
votes
33 answers

Gradle Error:Execution failed for task ':app:processDebugGoogleServices'

I am following this link to integrate Google sign-in in my android app.https://developers.google.com/identity/sign-in/android/start-integrating As given in last step on the above given page we have to include dependency compile…
gautamprajapati
  • 2,055
  • 5
  • 16
  • 31
134
votes
6 answers

How to run JUnit tests with Gradle?

Currently I have the following build.gradle file: apply plugin: 'java' sourceSets { main { java { srcDir 'src/model' } } } dependencies { compile files('libs/mnist-tools.jar', 'libs/gson-2.2.4.jar') …
letter Q
  • 14,735
  • 33
  • 79
  • 118
131
votes
5 answers

Difference between build.gradle (Project) and build.gradle (Module)

I am trying to add a dependency of Android Asynchronous Http Client into my project. So there are two build.gradle files in the project. As per my understanding, there are different kind of dependencies: One which defined on the root level of…
Anil Bhaskar
  • 3,718
  • 4
  • 33
  • 51
130
votes
25 answers

Android Studio Gradle: Error:Execution failed for task ':app:processDebugGoogleServices'. > No matching client found for package

I am trying to upgrade my google play services dependencies to 8.4.0 by following the example Google gives here, but I am getting the following error ('com.example.exampleapp' is a replacement for my app package name): Error:Execution failed for…
129
votes
2 answers

Why are there two build.gradle files in an Android Studio project?

After having imported an Eclipse project into Android Studio, I see two build.gradle files: 1 - \build.gradle 2 - \app\build.gradle The first version is shorter, the second version contains definitions for…
Sabuncu
  • 5,095
  • 5
  • 55
  • 89
125
votes
21 answers

Copy existing project with a new name in Android Studio

I would like to copy my Android project and create a new project from the same files just with a different name. The purpose of this is so I can have a second version of my app which is ad supported in the app store. I found this answer…
Mike
  • 6,751
  • 23
  • 75
  • 132
122
votes
6 answers

In Gradle, how to print out a message in the console / Event Log?

I'm trying to verify that my source and target paths are properly setup when I execute a deploy command. See the example below: (copied from: http://eppz.eu/blog/unity-android-plugin-tutorial-2/) android.libraryVariants.all { variant -> // Task…
chamberlainpi
  • 4,854
  • 8
  • 32
  • 63
120
votes
4 answers

How to import android project as library and NOT compile it as apk (Android studio 1.0)

I tried to import a project(projLib) as dependency for another project(projAPK). projAPK gradle has this : dependencies { compile project(':libs:NewsAPI') compile project(':projLib') } but when i sync the gradle it gives this…
Vic Zhou
  • 1,311
  • 2
  • 9
  • 6