有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

安卓错误:任务执行失败:应用程序:mergeDebugResources'>JAVAlang.OutOfMemoryError:无法创建新的本机线程

我得到以下错误:

Error:Execution failed for task ':app:mergeDebugResources'. java.lang.OutOfMemoryError: unable to create new native thread

这是我的项目梯度文件

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.安卓.tools.build:gradle:2.2.2+'

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

allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}

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

这是应用程序构建梯度文件

apply plugin: 'com.安卓.application'

安卓 {
    compileSdkVersion 21
    buildToolsVersion '21.1'

    defaultConfig {
        applicationId "my.app.id"
        minSdkVersion 15
        targetSdkVersion 19
        versionCode 7
        versionName "7.00"
//        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-安卓.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        pickFirst 'META-INF/license.txt'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/MANIFEST.MF'
    }
    lintOptions {
        checkReleaseBuilds false
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.安卓.support:support-v4:21.0'
    compile 'com.github.chrisbanes:PhotoView:1.3.0'
    compile 'com.google.安卓.gms:play-services-maps:9.4.0'
    // compile 'com.安卓.support:multidex:1.0.0'
    compile files('libs/acra-4.5.0.jar')
    compile files('libs/commons-io-2.4.jar')
    compile files('libs/IDTuniMagSDKAndroid.jar')
    compile files('libs/maps.jar')
    compile files('libs/picasso-2.5.2.jar')
    compile files('libs/numberpickerlib.jar')
    compile files('libs/PdfViewer.jar')
//    compile files('libs/httpmime-4.0.jar')
    compile files('libs/apache-mime4j-0.6.jar')
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.okhttp3:okhttp:3.4.1'
    compile 'com.squareup.okio:okio:1.10.0'
    compile 'com.leo.simplearcloader:simplearcloader:1.0.+'
    compile 'com.squareup.retrofit2:converter-gson:2.1.0'
    compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
    compile 'io.reactivex:rx安卓:1.0.1'
    compile 'com.akexorcist:RoundCornerProgressBar:2.0.3'
    compile 'com.github.jakob-grabner:Circle-Progress-View:v1.2.9'
}

我在构建项目时遇到了这个错误。因为这个原因,我也不能运行这个项目。甚至在模拟器中安装APK之前,也会发生这种情况

提前谢谢


共 (1) 个答案

  1. # 1 楼答案

    你似乎在清理你的项目。试着在你的^{中添加这个

    dexOptions {
            javaMaxHeapSize "4g"
        }