android tutorial - Debugging your Gradle errors in Android | Developer android - android app development - android studio - android app developement
- The following is an excerpt from Gradle - What is a non-zero exit value and how do I fix it?, see it for the full discussion.
Let's say you are developing an application and you get some Gradle error that appears that generally will look like so
- People say to clean and rebuild your project, or enable MultiDex, and when you try that, it just isn't fixing the problem.
There are ways to get more information, but the Gradle output itself should point at the actual error in the few lines above that message between :module:someTask FAILED and the last :module:someOtherTask that passed. Therefore, if you ask a question about your error, please edit your questions to include more context to the error.
So, you get a "non-zero exit value." Well, that number is a good indicator of what you should try to fix. Here are a few occur most frequently.
- 1 is a just a general error code and the error is likely in the Gradle output
- 2 seems to be related to overlapping dependencies or project misconfiguration.
- 3 seems to be from including too many dependencies, or a memory issue.
The general solutions for the above (after attempting a Clean and Rebuild of the project) are:
- 1 - Address the error that is mentioned. Generally, this is a compile-time error, meaning some piece of code in your project is not valid. This includes both XML and Java for an Android project.
- 2 & 3 - Many answers here tell you to enable multidex. While it may fix the problem, it is most likely a workaround. If you don't understand why you are using it (see the link), you probably don't need it. General solutions involve cutting back your overuse of library dependencies (such as all of Google Play Services, when you only need to use one library, like Maps or Sign-In, for example).