Java finished with non-zero exit value 2 - Android Gradle
I didn't know (by then) that "compile fileTree(dir: 'libs', include: ['*.jar'])" compile all that has jar extension on libs folder, so i just comment (or delete) this lines:
//compile 'com.squareup.retrofit:retrofit:1.9.0'
//compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
//compile 'com.squareup.okhttp:okhttp:2.2.0'
//compile files('libs/spotify-web-api-android-master-0.1.0.jar')
//compile files('libs/okio-1.3.0.jar')
and it works fine. Thanks anyway! My bad.
Gradle (Java finished with non-zero exit value 2)
This problem can be solved either by cleaning the project, and removing some unused libraries and methods from dependencies in build.gradle, OR by adding multidex support.
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
minSdkVersion 13
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
android studio java finished with non-zero exit value 2
I found the solution. I think Android Studio was using 2 java compilers, one built-in from android studio, and the other the one that I had installed in order to install Android Studio.
In Android Studio, On the menu File -> Project Structure : change the default JDK location directory to your own, in my case it was:
/usr/local/android-studio/jre
and I changed to
/usr/local/java/jdk1.8.0_111 #path_to_your_jdk
which is the version that I installed.
Java.exe finished with non-zero exit value 2 in Android Studio
The Android plugin for Gradle available in Android SDK Build Tools
21.1 and higher supports multidex as part of your build configuration. Make sure you update the Android SDK Build Tools tools and the Android
Support Repository to the latest version using the SDK Manager before
attempting to configure your app for multidex.
Setting up your app development project to use a multidex configuration requires that you make a few modifications to your app development project. In particular you need to perform the following steps:
- Change your Gradle build configuration to enable multidex
- Modify your manifest to reference the MultiDexApplication class
Modify your app Gradle build file configuration to include the support library and enable multidex output .
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
...
minSdkVersion 19
targetSdkVersion 23
...
// Enabling multidex support.
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.1'
}
In your manifest add the MultiDexApplication
class from the multidex support library to the application element.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android.multidex.myapplication">
<application
...
android:name="android.support.multidex.MultiDexApplication">
...
</application>
</manifest>
Edited
You can use
compile 'org.apache.httpcomponents:httpmime:4.5.1'
Read
https://developer.android.com/intl/es/tools/building/multidex.html
I am getting ****finished with non-zero exit value 2. how to resolve it?
I think there is a duplication in jama
library as you have mentioned
compile 'gov.nist.math:jama:1.0.3'
and
compile files('libs/Jama-1.0.3.jar')
Try removing one of them.
Gradle sync failed: process finished with non-zero exit 2
I had this problem 2 days ago and changing the JDK path worked for me..
I downloaded Oracle jdk..
I hope that helps you
and Happy coding.
Related Topics
Android Activity Life Cycle - What Are All These Methods For
Why Does an Image Captured Using Camera Intent Gets Rotated on Some Devices on Android
How to Detect When an Android App Goes to the Background and Come Back to the Foreground
How to Change Fontfamily of Textview in Android
How to Manually Include External Aar Package Using Gradle For Android
How to Add Dividers and Spaces Between Items in Recyclerview
Android Studio Suddenly Cannot Resolve Symbols
Horizontalscrollview Within Scrollview Touch Handling
Set Color of Textview Span in Android
How to Assign an Id to a View Programmatically
How to Get a List of Installed Android Applications and Pick One to Run
How to Add Parameters to Httpurlconnection Using Post Using Namevaluepair
Error in Launching Avd With Amd Processor
Best Practice For Storing and Protecting Private API Keys in Applications
How to Get Zoom Functionality For Images
Android Toolbar Center Title and Custom Font