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
1280
votes
12 answers

What's the difference between implementation, api and compile in Gradle?

After updating to Android Studio 3.0 and creating a new project, I noticed that in build.gradle there is a new way to add new dependencies instead of compile there is implementation and instead of testCompile there is testImplementation. Example: …
1074
votes
35 answers

Android Studio: Add jar as library?

I'm trying to use the new Android Studio but I can't seem to get it working correctly. I'm using the Gson library to serialize/deserialize JSON-objects. But the library somehow isn't included in the build. I had created a new project with just a…
808
votes
21 answers

How to add local .jar file dependency to build.gradle file?

I have tried to add my local .jar file dependency to my build.gradle file: apply plugin: 'java' sourceSets { main { java { srcDir 'src/model' } } } dependencies { runtime files('libs/mnist-tools.jar',…
letter Q
  • 14,735
  • 33
  • 79
  • 118
805
votes
54 answers

All com.android.support libraries must use the exact same version specification

After updating to android studio 2.3 I got this error message. I know it's just a hint as the app run normally but it's really strange. All com.android.support libraries must use the exact same version specification (mixing versions can lead to…
humazed
  • 74,687
  • 32
  • 99
  • 138
626
votes
20 answers

Can the Android layout folder contain subfolders?

Right now, I'm storing every XML layout file inside the 'res/layout' folder, so it is feasible and simple to manage small projects, but when there is a case of large and heavy projects, then there should be a hierarchy and sub-folders needed inside…
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
601
votes
35 answers

More than one file was found with OS independent path 'META-INF/LICENSE'

When I build my app, I get the following error: Error: Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'. More than one file was found with OS independent path 'META-INF/LICENSE' This is my build.gradle file: apply…
Cyrus
  • 8,995
  • 9
  • 31
  • 58
522
votes
26 answers

How to manually include external aar package using Gradle for Android

I've been experimenting with the new android build system and I've run into a small issue. I've compiled my own aar package of ActionBarSherlock which I've called 'actionbarsherlock.aar'. What I'm trying to do is actually use this aar to build my…
Miguel
  • 19,793
  • 8
  • 56
  • 46
520
votes
23 answers

How do I tell Gradle to use specific JDK version?

I can't figure out to get this working. Scenario: I have an application built with gradle The application uses JavaFX What I want Use a variable (defined per developer machine) which points to an installation of a JDK which will be used for…
bully
  • 5,525
  • 3
  • 22
  • 26
505
votes
6 answers

Gradle DSL method not found: 'runProguard'

I get an error after updating from my last project. Not a problem in my code but I'm having trouble with build.gradle. How can I fix it? build.gradle code here: apply plugin: 'android' android { compileSdkVersion 21 buildToolsVersion…
abaci
  • 5,226
  • 2
  • 12
  • 13
475
votes
28 answers

Building and running app via Gradle and Android Studio is slower than via Eclipse

I have a multi-project (~10 modules) of which building takes about 20-30 seconds each time. When I press Run in Android Studio, I have to wait every time to rebuild the app, which is extremely slow. Is it possible to automate building process in…
froger_mcs
  • 13,972
  • 5
  • 23
  • 34
462
votes
11 answers

Is it possible to declare a variable in Gradle usable in Java?

Is it possible to declare a variable in Gradle usable in Java ? Basically I would like to declare some vars in the build.gradle and then getting it (obviously) at build time. Just like a pre-processor macros in C/C++... An example of declaration…
klefevre
  • 8,595
  • 7
  • 42
  • 71
347
votes
24 answers

Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation'

I have replaced every occurrence of compile by implementation in my project's build.gradle, but I'm still getting this warning : I tried to look for "compile " in the whole project but no match was found. So what could be the cause?
Rob
  • 4,123
  • 3
  • 33
  • 53
332
votes
12 answers

How can I use external JARs in an Android project?

I have created an Android project and added an external JAR (hessian-4.0.1.jar) to my project. I then added the JAR to the build path and checked it off in Order and Export. Order and Export is ignored it seems, and all classes from the external JAR…
Fredrik Olsson
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
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
1
2 3
99 100