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
119
votes
9 answers

Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ

When building I get the following error: Conflict with dependency 'com.android.support:support-annotations'. Resolved versions for app (23.1.0) and test app (23.0.1) differ. These are my gradle dependencies dependencies { compile…
barq
  • 3,681
  • 4
  • 26
  • 39
117
votes
8 answers

Allow insecure protocols, android gradle

I recently updated my android studio to Arctic Fox and got an error in my project A problem occurred configuring root project 'so10'. > Could not resolve all dependencies for configuration ':classpath'. > Using insecure protocols with…
WISHY
  • 11,067
  • 25
  • 105
  • 197
117
votes
35 answers

Android Studio - Failed to notify project evaluation listener error

Following is the build.gradle code in Android Studio apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "com.sg.blahblah" minSdkVersion 15 …
userash
  • 1,353
  • 3
  • 9
  • 13
117
votes
8 answers

Add resources and config files to your JAR using Gradle

How do I add config files or any other resources into my jar using gradle? My project structure: src/main/java/com/perseus/.. --- Java packages (source files) src/main/java/config/*.xml --- Spring config files Expected jar…
Pritesh Mhatre
  • 3,847
  • 2
  • 23
  • 27
116
votes
18 answers

Android dependency has different version for the compile and runtime

After updating Android Studio from Canary 3 to Canary 4, the following error is thrown at the build time. Android dependency 'com.android.support:support-support-v4' has different version for the compile (25.2.0) and runtime (26.0.0-beta2)…
DroidLearner
  • 2,115
  • 5
  • 31
  • 50
110
votes
11 answers

How can I force Gradle to set the same version for two dependencies?

I use the following two dependencies: compile 'com.google.guava:guava:14.0.1' compile 'com.google.guava:guava-gwt:14.0.1' Both must be the same version to work correctly. Since my other dependencies use a higher version, Gradle uses different…
Michael
  • 32,527
  • 49
  • 210
  • 370
105
votes
8 answers

How to define and call custom methods in build.gradle?

As part of my project, I need to read files from a directory and do some operations all these in build script. For each file, the operation is the same(reading some SQL queries and execute it). I think its a repetitive task and better to write…
Tomin
  • 1,898
  • 3
  • 18
  • 23
105
votes
6 answers

Extract common methods from Gradle build script

I have a Gradle build script (build.gradle), in which I created some tasks. These tasks consist mostly of method calls. The called methods are also in the build script. Now, here's the situation: I am creating a fair amount of build scripts, which…
Pieter VDE
  • 2,195
  • 4
  • 25
  • 44
102
votes
4 answers

Could not find method android() for arguments

I've been trying to import a project to Android Studio and this is where I am stuck, there is a similar question on Stack Overflow but it did not provide a solution to my particular error. This is my error log: C:\
100
votes
16 answers

Gradle - Could not find or load main class

I'm trying to run a very simple project using Gradle and running into the following error when using the gradlew run command: could not find or load main class 'hello.HelloWorld' Here is my file structure: SpringTest -src -hello …
kibowki
  • 4,206
  • 16
  • 48
  • 74
99
votes
4 answers

What's the difference between "minifyEnabled" and "useProguard" in the Android Plugin for Gradle?

I see that the Android Plugin for Gradle has a minifyEnabled property as well as a useProguard property, as follows: android { buildTypes { debug { minifyEnabled true useProguard false } release { …
Adil Hussain
  • 30,049
  • 21
  • 112
  • 147
99
votes
11 answers

How to add Apache HTTP API (legacy) as compile-time dependency to build.grade for Android M?

As mentioned here, Android M will not support the Apache HTTP API. The docs state to: use the HttpURLConnection class instead. or To continue using the Apache HTTP APIs, you must first declare the following compile-time dependency in your…
97
votes
16 answers

Getting error says - "Entry name 'res/layout/test_toolbar.xml' collided" while creating signed apk

I have updated my android studio from 3.5.x to 3.6 today and getting an error while generating signed apk for build variant showing the following message - Entry name 'res/layout/test_toolbar.xml' collided I don't have any layout named like this…
A S M Sayem
  • 2,010
  • 2
  • 21
  • 28
97
votes
17 answers

java.lang.NullPointerException (no error message)

I know that this question of mine has been asked many times and I did follow most of the answers but none of those helped me. So this is my problem, whenever I sync my project it always fails. Here is how the gradle console look like: Executing…
sweetzyl pili
  • 1,023
  • 1
  • 7
  • 13
97
votes
8 answers

IntelliJ IDEA and Gradle - Cannot be applied to '(groovy.lang.Closure)'

I have a Gradle file which, whenever I load open it in IntelliJ IDEA 14.1.5, shows IDE errors for the entire file. Namely all the errors seem to be either: java.lang.String errors or groovy.lang.Closure errors I've tried clearing the file's…
Seb Charrot
  • 2,816
  • 1
  • 22
  • 24