Skip to main content

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.

Filter by
Sorted by
Tagged with
1591 votes
39 answers
924k views

How can you get the build/version number of your Android application?

I need to figure out how to get or make a build number for my Android application. I need the build number to display in the UI. Do I have to do something with AndroidManifest.xml?
Fahad Ali Shaikh's user avatar
1293 votes
12 answers
536k views

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 ...
humazed's user avatar
  • 76.2k
1079 votes
36 answers
791k views

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 ...
Ozzie's user avatar
  • 11.7k
824 votes
22 answers
953k views

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 { ...
letter Q's user avatar
  • 15.1k
806 votes
54 answers
394k views

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 ...
humazed's user avatar
  • 76.2k
629 votes
20 answers
212k views

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 ...
Paresh Mayani's user avatar
625 votes
38 answers
538k views

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/...
Cyrus's user avatar
  • 9,355
556 votes
23 answers
837k views

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 ...
bully's user avatar
  • 5,884
533 votes
28 answers
531k views

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 ...
Miguel's user avatar
  • 20k
506 votes
6 answers
173k views

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 { ...
abaci's user avatar
  • 5,246
476 votes
28 answers
228k views

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. ...
froger_mcs's user avatar
468 votes
11 answers
191k views

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 ...
klefevre's user avatar
  • 8,705
348 votes
23 answers
261k views

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 ...
Rob's user avatar
  • 4,184
332 votes
12 answers
263k views

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 ...
user avatar
283 votes
24 answers
386k views

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....
AndroidDev's user avatar
  • 5,523
261 votes
11 answers
257k views

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 ...
smeeb's user avatar
  • 28.9k
246 votes
15 answers
111k views

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 { ...
Rahul Garg's user avatar
  • 8,570
241 votes
35 answers
400k views

Android Material and appcompat Manifest merger failed

I have next grade dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0-rc01' implementation 'com.android....
Евгений Усов's user avatar
241 votes
5 answers
237k views

Install / upgrade gradle on Mac OS X

How do I install/upgrade gradle for Mac?
mllm's user avatar
  • 17.2k
224 votes
2 answers
117k views

What is the syntax for writing comments in build.gradle file?

Looking down this build.gradle file apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "package....
Machado's user avatar
  • 14.3k
212 votes
9 answers
117k views

How to run Gradle test when all tests are UP-TO-DATE?

I have my grade script set up. When I execute the Gradle build, everything is working and it runs the jUnit tests. After that when I run the Gradle test I get the following: C:\Users\..\..\Project&...
USer22999299's user avatar
  • 5,524
209 votes
6 answers
108k views

What does transitive = true in Gradle exactly do (w.r.t. crashlytics)?

What does Gradle transitive = true do exactly? It is not clear from the Gradle documentation. This is in the context of compile within build.gradle. In my case I'm depending Android's crashlytics. ...
Steve Kuo's user avatar
  • 62.6k
205 votes
4 answers
235k views

In Gradle, is there a better way to get Environment Variables?

In several Tasks, I reference jars in my home folder. Is there a better way to get Environment Variables than ENV = System.getenv() HOME = ENV['HOME'] task copyToServer(dependsOn: 'jar', type: Copy) {...
Nicholas Marshall's user avatar
204 votes
32 answers
183k views

DELETE_FAILED_INTERNAL_ERROR Error while Installing APK

I am using Android Studio 2.2 Preview. I am facing the issue Failure: Install failed invalid apk Error: While installing apk, I have made changes in build.gradle but could not retrack it, please ...
Ali Sher Kashif's user avatar
201 votes
12 answers
340k views

Creating runnable JAR with Gradle

Until now I created runnable JAR files via the Eclipse "Export..." functionallity but now I switched to IntelliJ IDEA and Gradle for build automation. Some articles here suggest the "application" ...
Hannes's user avatar
  • 5,192
200 votes
46 answers
578k views

Gradle: Execution failed for task ':processDebugManifest'

I'm getting a gradle error at building since yesterday - it just came randomly.... Full stacktrace here: My project depends on multiple libraries and it built without any problems until yesterday (...
Lukas Olsen's user avatar
  • 5,424
194 votes
14 answers
115k views

Problem duplicate class androidx.lifecycle.viewmodel found in modules

I got these errors when I try to run the emulator Duplicate class androidx.lifecycle.ViewModelLazy found in modules jetified-lifecycle-viewmodel-ktx-2.3.1-runtime (androidx.lifecycle:lifecycle-...
Martin GGR's user avatar
  • 1,941
181 votes
10 answers
248k views

Getting Gradle dependencies in IntelliJ IDEA using Gradle build

Grade build, even from inside IntelliJ IDEA does not put the dependencies into the "External Libraries" folder, so these classes don't show up as suggestions in the editor and when I manually add them ...
Andrew's user avatar
  • 3,008
178 votes
15 answers
199k views

Adding local .aar files to Gradle build using "flatDirs" is not working

I'm aware of this question: Adding local .aar files to my gradle build but the solution does not work for me. I tried adding this statement to the top level of my build.gradle file: repositories { ...
Alex Dmitriev's user avatar
178 votes
10 answers
307k views

Android Studio: Plugin with id 'android-library' not found

I've been trying to get ActionBarSherlock to work and having some issue. One issue I've come across is the following message when trying to build it: Plugin with id 'android-library' not found ...
Michael's user avatar
  • 4,040
167 votes
20 answers
426k views

android studio 0.4.2: Gradle project sync failed error

After updating to 0.4.2 I get this error when opening a project: 'Gradle project sync failed. Basic functionality (e.g. editing, debugging) will not work proprerly' The event log shows this: Error ...
Carlos Taylor's user avatar
164 votes
8 answers
297k views

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 ...
Jens D's user avatar
  • 4,431
162 votes
20 answers
85k views

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 ...
Code-Apprentice's user avatar
162 votes
17 answers
144k views

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 ...
carvaq's user avatar
  • 1,846
155 votes
12 answers
118k views

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 > ...
Gabriel Vicente Albasini Garau's user avatar
151 votes
5 answers
98k views

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 ...
Bhuvanesh BS's user avatar
  • 13.5k
146 votes
11 answers
110k views

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's user avatar
  • 12.1k
138 votes
33 answers
282k views

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 ...
gautamprajapati's user avatar
137 votes
5 answers
75k views

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 ...
Anil Bhaskar's user avatar
  • 3,878
136 votes
23 answers
137k views

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 ':...
Maverick.pe's user avatar
  • 1,917
136 votes
6 answers
268k views

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/...
letter Q's user avatar
  • 15.1k
135 votes
6 answers
203k views

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/) ...
chamberlainpi's user avatar
133 votes
2 answers
66k views

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 - <PROJECT_ROOT>\build.gradle 2 - <PROJECT_ROOT>\app\build.gradle The first version is ...
Sabuncu's user avatar
  • 5,225
130 votes
25 answers
171k views

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 ...
sean's user avatar
  • 3,634
129 votes
8 answers
174k views

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 ':...
WISHY's user avatar
  • 11.7k
126 votes
20 answers
174k views

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 ...
Mike's user avatar
  • 6,811
125 votes
8 answers
203k views

cvc-complex-type.2.4.a: Invalid content was found starting with element 'base-extension'. One of '{layoutlib}' is expected

I am facing this issue many times when i download project from github i am using new Android studio(bumble bee) please help me if any body knows https://github.com/fjbatresv/arcore_solar_system.git (...
Anil Dhiman's user avatar
  • 1,409
124 votes
9 answers
222k views

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 --- ...
Pritesh Mhatre's user avatar
123 votes
35 answers
261k views

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 { ...
userash's user avatar
  • 1,443
121 votes
11 answers
201k views

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 ...
Michael's user avatar
  • 33.1k

1
2 3 4 5
189