This problem has troubled me for two days, now solve the problem of this trouble, I think it is necessary to blog the form of my sad experience, in the online search for a lot of information about this, most of them are said to compile the jar package, or libs repetition of the same (I use as), But I looked carefully several times my builde.gradle file, no this problem exists, so I was very puzzled, a few toss, I think or from the wrong log to find the source of the bug, found Java.exe finished with Non-zero exit The value 2 was also caused by the com.android.dex.DexIndexOverflowException error, so I found the answer on the Overflowstack Web (http://stackoverflow.com/ Questions/33590477/unexpected-top-level-exception-com-android-dex-dexindexoverflowexception-mergin), different Version of the same library and May is unnecessary dependencies (there are different versions of the class library and no necessary dependencies), which will cause such errors, Since the Gradle plugin 0.14 .0 and the Build Tools 21.1.0 you can use the multidexsupport. To resolve this issue, add compile ' com.android.support in the defaultconfig in your builde.gradle file multidexenabled true,dependencies: multidex:1.0.0 ', so that miracles happen.
Com.android.dex.DexIndexOverflowException merging dependencies or error that Java.exe finished with Non-zero exit value 2