Android with Gradle (Java terminated with non-zero exit value 2)

This is my .gradle file:

apply plugin: 'com.android.application' android { compileSdkVersion 21 buildToolsVersion "21.1.2" defaultConfig { applicationId "com.test.test" minSdkVersion 15 targetSdkVersion 21 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } packagingOptions { exclude 'META-INF/license.txt' exclude 'META-INF/LICENSE' exclude 'META-INF/notice.txt' exclude 'META-INF/NOTICE' } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:21.0.3' compile 'com.mcxiaoke.volley:library:1.0.15' compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.17' } 

When I try to run an Android application, I get the following error:

Error: execution completed for task ': app: dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: process 'command' / usr / lib / jvm / java-8-oracle / bin / java '' terminated with non- -zero output value 2

I get this error when I add the Jackson library to the gradle file. After trying for a while, I found that the Jackson library is compatible with Android apps, and faster than other libraries like gson.

How can i solve this? I am new to Android.

+7
android rest jackson android-volley gradle
source share
5 answers

I think you need to change jav jv jvm jvm v8 for jdk7. This link may help you: Is it possible to use Java 8 for Android development?

Another possible error question of its error is a clean gradle before assembly. And replace your Jackson library with this:

 compile 'com.fasterxml.jackson.core:jackson-databind:2.2.+' compile 'com.fasterxml.jackson.core:jackson-core:2.2.+' compile 'com.fasterxml.jackson.core:jackson-annotations:2.2.+' 
+3
source share

Awkwardly this problem can have several reasons. In my case, this was due to exceeding the maximum line number. This is so annoying that the Android Studio message doesn’t mean anything, but for some reason I found a solution, as shown below:

https://developer.android.com/tools/building/multidex.html

You need to create a class that extends MultiDexApplication and override the following method:

  @Override protected void attachBaseContext(Context base) { super.attachBaseContext(base); MultiDex.install(this); } 

Remember to add the internal "name" tag to your AndroidManifest file, as described in the link above.

+3
source share

I copied the required library inside my_project / app / libs, and also added a dependency in build.gradle. So, in my case, I deleted the library that I copied to my_project / app / libs. Since gradle supports all dependency, I do not need to put the library in / libs. This fixed my problem.

+1
source share

Perhaps you have a dependency that causes incompatibility

eg:

+1
source share

Fixing the JDK path solves the problem.

Right-click Project> Open Module Settings> SDK Location> In the JDK section, specify the path to the JDK folder.

+1
source share

All Articles