android - 建议为运行 jack 的 Gradle 守护程序使用更大的堆

标签 android gradle jack

我是 gradle 的新手。我目前尝试在 gradle 设置中将一个研究 Android 应用程序升级到 Java 1.8,它提示我将 jackOptions 启用为“true”,这样我就可以在我的应用程序中使用 lambda 表达式。

这是我当前的 gradle 选项:

构建.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    dexOptions{
        javaMaxHeapSize "4g"
    }

    defaultConfig {
        applicationId "com.bmw.www.team10"
        minSdkVersion 23
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        multiDexEnabled true

        jackOptions{
            enabled true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.google.android.gms:play-services-ads:9.6.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.google.android.gms:play-services:9.6.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha9'
    compile 'com.android.support:cardview-v7:24.2.1'
}

gradle.properties

# 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: -Xmx2048m -XX:MaxPermSize=2048m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=2048m -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

当我尝试构建我的项目时,这会在 gradle 控制台中循环 10 分钟

A larger heap for the Gradle daemon is recommended for running jack.

It currently has 1024 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to at least 1536 MB.
To do this set org.gradle.jvmargs=-Xmx1536M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html

最佳答案

在 gradle.properties 中取消注释这一行:

# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

关于android - 建议为运行 jack 的 Gradle 守护程序使用更大的堆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40143251/

相关文章:

android - Gradle 和 Android : how to use the latest available build tools?

gradle - 如何制作自定义 gradle 模板?

groovy - 使用正则表达式过滤文件名

android 上的 Android 推送通知声音丢失(不工作)背景和前景

android - 使用 MediaCodec 和 MediaMuxer 编码和混合视频

android - 如何减小apk的大小

java - 将操作栏的标题从 Fragment 更改为 Activity

ffmpeg - 如何在 MAC OS 上使用带有 Jack Audio Connection Kit 的 Wowza 媒体服务器作为输入?

javascript - 通过网络将系统音频流式传输到 Web 浏览器 (javascript)

c - jack 中的 "32 bit float mono audio"