Reputation: 29
For faster builds, increase the maximum heap size for the Gradle daemon to more than 3072 MB.
To run dex in process, the Gradle daemon needs a larger heap.
To do this set org.gradle.jvmargs=-Xmx3072M in the project gradle.properties. It currently has approximately 989 MB.
For more information see https://docs.gradle.org/current/userguide/build_environment.html Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_102\bin\java.exe'' finished with non-zero exit value 1 :app:transformClassesWithDexForDebug FAILED
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "videoplayer.avkinfosoft.com.videoplayer"
minSdkVersion 11
targetSdkVersion 24
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize "2g"
}
packagingOptions
{
pickFirst 'META-INF/license.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
compile 'com.google.firebase:firebase-ads:9.4.0'
}
Project-wide Gradle settings.
IDE (e.g. Android Studio) users: Gradle settings configured through the IDE will override any settings specified in this file.
For more details on how to configure your build environment visit http://www.gradle.org/docs/current/userguide/build_environment.html
Specifies the JVM arguments used for the daemon process. The setting is particularly useful for tweaking memory settings. Default value: -Xmx10248m -XX:MaxPermSize=256m org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
When configured, Gradle will run in incubating parallel mode. This option should only be used with decoupled projects. More details, visit http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects org.gradle.parallel=true
org.gradle.jvmargs=-Xmx1024m
org.gradle.daemon=true
When configured, Gradle will run in incubating parallel mode. This option should only be used with decoupled projects. More details, visit
http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects org.gradle.parallel=true
org.gradle.configureondemand=true
<application
android:allowBackup="true"
android:icon="@drawable/logo"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/AppTheme"
tools:replace="android:theme,android:icon">
dexOptions {
javaMaxHeapSize "2g"
}
Error:Error: A fatal exception has occurred. Program will exit.
Error:Error: A fatal exception has occurred. Program will exit.
Error:Error: A fatal exception has occurred. Program will exit.
Error:Error: Could not create the Java Virtual Machine.
Error:Error: Could not create the Java Virtual Machine.
Error:Invalid maximum heap size: -Xmx4g
Error:The specified size exceeds the maximum representable size.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program
Files\Java\jdk1.8.0_102\bin\java.exe'' finished with non-zero exit value 1
Error:Error: A fatal exception has occurred. Program will exit.
Error:The specified size exceeds the maximum representable size.
Error:Invalid maximum heap size: -Xmx4g
Error:Error: Could not create the Java Virtual Machine.
Error:The specified size exceeds the maximum representable size.
Error:Invalid maximum heap size: -Xmx4g
To do this set org.gradle.jvmargs=-Xmx5120M in the project gradle.properties.
Error:The specified size exceeds the maximum representable size.
Error:The specified size exceeds the maximum representable size.
Error:Invalid maximum heap size: -Xmx4g
Error:Error: Could not create the Java Virtual Machine. :app:transformClassesWithDexForDebug FAILED
Error:Error: A fatal exception has occurred. Program will exit.
Error:Error: Could not create the Java Virtual Machine.
Error:Invalid maximum heap size: -Xmx4g
It currently has approximately 989 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 5120 MB.
To run dex in process, the Gradle daemon needs a larger heap.
Upvotes: 0
Views: 516
Reputation: 75788
You should add javaMaxHeapSize
in build.gradle
section .
android {
compileSdkVersion //
buildToolsVersion //
dexOptions {
javaMaxHeapSize "4g"
}
You can visit for more information Android Gradle: What is javaMaxHeapSize “4g”?
Upvotes: 1
Reputation: 372
Add android:largeHeap="true"
in your MenifestFile in application tag.
Upvotes: 2