android studio中的堆大小问题

时间:2016-05-25 13:39:51

标签: android android-studio android-gradle heap

使用android studio

运行我的应用程序时出现以下问题
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 5120 MB.
To do this set org.gradle.jvmargs=-Xmx5120M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
:_4SaleApp:validateDebugSigning
:_4SaleApp:packageDebug
:_4SaleApp:zipalignDebug
:_4SaleApp:fullDebugBuildInfoGenerator
:_4SaleApp:assembleDebug

任何人都可以告诉我如何解决这个问题吗?

修改

apply plugin: 'com.android.application'

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

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'
    defaultConfig {
        applicationId "com.forsale.forsale"
        minSdkVersion 15
        targetSdkVersion 15
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    packagingOptions {

        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LGPL2.1'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'lib/armeabi-v7a/libblasV8.so'
    }
    dexOptions {
        incremental true
        javaMaxHeapSize "10g"
    }
    sourceSets {
        main {
            jni.srcDirs = []
            jniLibs.srcDirs = ['libs']
        }
    }
    productFlavors {
    }

    /*lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }*/
}

repositories {

    jcenter()

    maven {
        url 'https://zendesk.artifactoryonline.com/zendesk/repo/'
    }

    maven {
        url "https://repo.commonsware.com.s3.amazonaws.com"
    }

    maven {
        url "https://jitpack.io"
    }

    maven {
        url "http://appboy.github.io/appboy-android-sdk/sdk"
    }

    maven {
        url 'https://zendesk.artifactoryonline.com/zendesk/repo'
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':gestureimageview')
    compile project(':ffmpeg4android_lib')
    compile 'com.android.support:multidex:1.0.0'
    compile files('libs/universal-image-loader-1.9.5.jar')
    compile files('libs/android-hipmob-2.9.8.jar')
    compile files('libs/HockeySDK-3.5.0.jar')
    compile files('libs/httpclient-4.3.jar')
    compile files('libs/httpcore-4.3.jar')
    compile files('libs/libphonenumber-5.2v1.5.jar')
    compile files('libs/NineOldAndroid-2.4.0.jar')
    compile files('libs/org.apache.commons.io.jar')
    compile files('libs/zbar.jar')
    compile files('libs/quickblox-android-sdk-core-2.5.jar')
    compile files('libs/quickblox-android-sdk-chat-2.5.jar')
    compile files('libs/quickblox-android-sdk-content-2.5.jar')
    compile files('libs/quickblox-android-sdk-messages-2.5.jar')
    compile files('libs/renderscript-v8.jar')
    compile('com.appboy:android-sdk-ui:1.11.2') {
        exclude group: 'com.android.support', module: 'multidex'
    }
    compile group: 'com.zendesk', name: 'sdk', version: '1.6.0.1'
    compile 'com.zopim.android:sdk:1.1.0'
    compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
    compile 'com.github.jaydeepw:poly-picker:v1.0.22'
    compile 'com.github.bmelnychuk:atv:1.2.+'
    compile 'com.wdullaer:materialdatetimepicker:2.0.2'
    compile 'com.danikula:videocache:2.3.4'
    compile 'com.instabug.library:instabug:2.+'
    //compile 'com.google.android.gms:play-services:8.3.0'
    //compile 'com.google.android.gms:play-services-ads:8.3.0'
    //compile 'com.google.android.gms:play-services-auth:8.3.0'
    //compile 'com.google.android.gms:play-services-gcm:8.3.0'
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.android.gms:play-services-ads:8.4.0'
    compile 'com.google.android.gms:play-services-auth:8.4.0'
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.google.android.gms:play-services-gcm:8.4.0'
    compile 'com.android.support:support-v4:23.2.1'
}

1 个答案:

答案 0 :(得分:3)

查看我的ScreenShot并添加以下行:

在build.gradle()上添加

android {
...
 dexOptions {
        javaMaxHeapSize "3g"

    }
..
}

在gradle.properties上添加

org.gradle.jvmargs=-Xmx5120M

Check this