openjdk 平台二进制文件在构建 android 应用程序时使用了太多内存

openjdk platform binary use so much memory when build android app

当我构建 android 应用程序时,可能需要 5 到 15 分钟。 如何解决内存问题。有没有办法减少内存消耗? 如何加快构建速度?

我的build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.xxx.xxx"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        jackOptions {
            enabled true
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    compile('com.philliphsu:bottomsheetpickers:2.3.3') {
        exclude group: 'com.android.support', module: 'appcompat-v7'
        exclude group: 'com.android.support', module: 'design'
        exclude group: 'com.android.support', module: 'gridlayout-v7'
    }

    compile 'com.android.support:appcompat-v7:25.3.1'
    compile 'com.android.support:design:25.3.1'
    compile 'com.android.support:gridlayout-v7:25.3.1'
    compile 'com.philliphsu:bottomsheetpickers:2.3.3'
    compile 'com.vk:androidsdk:1.6.8'
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.jakewharton:butterknife:8.4.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
}

还有我的gradle.properties

org.gradle.jvmargs=-Xmx1536m
org.gradle.daemon=true
org.gradle.parallel=true

同时添加报告

为什么需要这么长时间以及如何加快项目的组装速度?

解决方案 - 不使用 Jack。阅读此处 https://developer.android.com/studio/preview/features/java8-support.html

谢谢@BladeCoder

每个人都会给出不同的不同意见,但我最近通过禁用我的防病毒软件来修复它。禁用防火墙,因为它会中断 Gradle 守护进程的启动,因此 OpenJDK 平台二进制文件将继续执行 n 次,最终系统会发生内存溢出崩溃。

更新:确保无线热点已关闭。最重要的是,在构建项目时,热点不能打开。

这样做,稍后谢谢我

Starting Gradle Daemon...

Gradle Daemon started in 4 s 291 ms

Starting Gradle Daemon...

Gradle Daemon started in 5 s 664 ms

Starting Gradle Daemon...

Gradle Daemon started in 2 s 210 ms

Starting Gradle Daemon...

Gradle Daemon started in 7 s 258 ms