Android &引用;OutOfMemoryError:无法创建新的本机线程;在添加Google Play服务之后

Android &引用;OutOfMemoryError:无法创建新的本机线程;在添加Google Play服务之后,android,google-play-services,Android,Google Play Services,我正在尝试实现一个广告网络的SDK,它需要我添加Google Play服务 现在,当我在gradle文件中添加compile'com.google.android.gms:play services:9.6.0'时,我得到一个错误(见下图)。这可能是因为已经安装了一些其他库,但我不知道如何修复这些文件 格拉德尔项目: buildscript { dependencies { classpath 'com.android.tools.build:gradle:2.2.0'

我正在尝试实现一个广告网络的SDK,它需要我添加Google Play服务

现在,当我在gradle文件中添加
compile'com.google.android.gms:play services:9.6.0'
时,我得到一个错误(见下图)。这可能是因为已经安装了一些其他库,但我不知道如何修复这些文件

格拉德尔项目:

buildscript {
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}
模块梯度:

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
    }
}

dependencies {
    compile 'com.google.android.gms:play-services-appindexing:9.6.1'
    compile 'com.google.android.gms:play-services:9.6.0' // The new line
}
apply plugin: 'com.google.gms.google-services'
错误:

错误:任务“:appName:mergeDebugResources”的执行失败。 java.lang.OutOfMemoryError:无法创建新的本机线程


如前所述:没有新行,它运行得非常完美。

因为您添加了'com.google.android.gms:play services appindexing:9.6.1' 然后添加compile'com.google.android.gms:play services:9.6.0'

如果您不需要所有的播放服务,只需添加您需要的内容,因为这样会生成一个大的apk文件,有时还会出现OutOfMemoryError

如果要通过将此行添加到项目的“gradle属性”来更改JVM(Heapsize)的配置:

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

问题似乎出在您的开发机器上,因为您甚至无法编译。您看到帮助诊断问题的方法了吗?基于此,每当JVM从操作系统请求新线程时,就会导致您的错误
java.lang.OutOfMemoryError:无法创建新的本机线程
。每当底层操作系统无法分配新的本机线程时,就会抛出此
OutOfMemoryError
。只需查看上面的链接即可了解此问题的可能原因和解决方案。有关详细信息,请查看此相关内容。注释appindexing行和将另一行添加到支架属性都不会改变任何内容。请尝试使用对我有用的“play services:9:0:2”