java - android 错误 :Execution failed for task ':app:mergeDebugResources' . > java.lang.OutOfMemoryError: 无法创建新的 native 线程

标签 java android multithreading android-studio gradle

我收到以下错误:

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

这是我的项目gradle文件

// 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.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
}

这是应用程序构建 gradle 文件

apply plugin: 'com.android.application'

android {
    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-android.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.android.support:support-v4:21.0'
    compile 'com.github.chrisbanes:PhotoView:1.3.0'
    compile 'com.google.android.gms:play-services-maps:9.4.0'
    // compile 'com.android.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:rxandroid:1.0.1'
    compile 'com.akexorcist:RoundCornerProgressBar:2.0.3'
    compile 'com.github.jakob-grabner:Circle-Progress-View:v1.2.9'
}

我在构建项目时遇到此错误。因此,我也无法运行该项目。即使在模拟器中安装 APK 之前也会发生这种情况。

提前致谢。

最佳答案

看来你清理了你的项目。尝试将其添加到你的 build.gradle

dexOptions {
        javaMaxHeapSize "4g"
    }

关于java - android 错误 :Execution failed for task ':app:mergeDebugResources' . > java.lang.OutOfMemoryError: 无法创建新的 native 线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40365120/

相关文章:

Java ArrayList 添加超出当前大小的项目

c# - 剪刀布石头算法

Android getSupportedVideoSizes 总是返回 null

java - 沙盒静态字段

python - PyQt:将信号连接到插槽以启动后台操作

java - 参数太少的 ObjectDB Select 查询

java - 如何从数组中计算唯一的 "mode"?

android - 如何半透明菜单android

java - Android定时器抛出空指针异常

在 C 中从 main 调用 void* 函数