Read complete story

Android Gradle Error “java finished with non-zero exit value 2”

In this blog,

I have talked about the reason behind Android Gradle error.

“java finished with non-zero exit value 2”

This is a very general problem when we have used many libraries to build our android project.

So, I will give the answer and the some suggestions for avoiding this gradle error.

Explaination:

This issue is quite possibly due to exceeding the 65K methods dex limit imposed by Android.

And if you had put a unnecessary compile library code in build.gradle.

Which was causing over 65k methods, so removed it,  used only neccessary compile library code gradle sync, cleaned project, and then ran again and then this error stopped. I needed just maps, analytics and gcm so i put these lines and synced project

 

After that your problem should be solved.

Note: If you want to count the total methods in your project then you can use the following link
http://inloop.github.io/apk-method-count/
By simply upload your apk file.


After all this If still your project is giving this error, So you have to enable the multidex in your project.

And create a class

 

that extends Application class

 

also add in OnCreate method too

 

. . .

Comment

Add Your Comment

Be the first to comment.

css.php
Hire Us!
Brief us about your requirements and we'll get back to you.
Woo! Hooy!
We have just recieved your project brief and our expert will contact you shortly.
Send Again
Close