本文介绍了要在进程中运行dex,Gradle守护程序需要更大的堆.目前大约有910 MB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我运行我的应用程序时,都会收到此Gradle错误.错误是:

I am getting this Gradle error every time I run my app. The error is:

要加快构建速度,请将Gradle守护程序的最大堆大小增加到2048 MB以上.

For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.

为此,请在项目gradle.properties中设置org.gradle.jvmargs = -Xmx2048M. 有关更多信息,请参见 https://docs.gradle.org/current/userguide/build_environment.html

To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties. For more information see https://docs.gradle.org/current/userguide/build_environment.html

这是我的build.gradle(Module:app)文件:

Here is my build.gradle (Module:app) file:

apply plugin: 'com.android.application'

    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.3"

        defaultConfig {
            applicationId "mobileapp.tech2dsk"
            minSdkVersion 15
            targetSdkVersion 23
            versionCode 1
            versionName "1.0"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        testCompile 'junit:junit:4.12'
        compile 'com.android.support:appcompat-v7:23.3.0'
        compile 'com.android.support:design:23.3.0'
    }

这是我的build.gradle(Project)文件:

And here is my build.gradle(Project) file:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我的gradle.properties文件:

and here is my gradle.properties file :

# 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=-Xmx2048m -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

推荐答案

在Build.gradle中添加

Add in your Build.gradle

android {
 dexOptions {
    javaMaxHeapSize "4g"
  }
}

更多信息- Android Gradle:什么是javaMaxHeapSize"4g"?

这篇关于要在进程中运行dex,Gradle守护程序需要更大的堆.目前大约有910 MB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:54