Question:
I'm new to Android and I want to build an application based on DB connections but I get this error and I don't know how to solve it.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 1
this is what i did with the build.gradle(Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.example.stroler.vidapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile files('libs/apache-httpcomponents-httpclient.jar')
compile files('libs/http-core-4.1.jar')
compile files('libs/httpclient-4.5.1.jar')
compile files('libs/json-20140107.jar')
compile files('libs/jsr166.jar')
}
Answer:
El error: Error:Execution failed for task ‘:app:transformClassesWithDexForDebug’. :
Error:Execution failed for task
':app:transformClassesWithDexForDebug'.
> com.android.ide.common.process.ProcessException:
It can be avoided by adding inside your build.gradle
the option:
defaultConfig {
...
...
...
multiDexEnabled true
}
Make the change in your build.gradle
and sync your project with the build.gradle
file.
Regarding the error:
org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_66\bin\java.exe'' finished with non-zero exit value 1
It happens regularly due to lack of memory, I'm just working on a PC that regularly had this problem, the temporary solution was to restart Android Studio
to make it work correctly.
You could fix this problem by adding this option inside your build.gradle
file:
dexOptions {
...
...
javaMaxHeapSize "3g"
}
in my case I have configured a HeapSize
of 3GB.
As another option you can increase your HeapSize
from Android Studio
:
https://stackoverflow.com/questions/18723755/android-studio-how-to-increase-allocated-heap-size (english)