android - 添加 Google Play 服务后 "OutOfMemoryError: unable to create new native thread"

标签 android google-play-services

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

现在,当我将 compile 'com.google.android.gms:play-services:9.6.0' 添加到我的 gradle 文件时,出现错误(见底部)。这可能是由于已经安装了一些其他库,但我不知道如何修复这些文件。

项目等级:

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'

错误:

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

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

最佳答案

因为您添加了“com.google.android.gms:play-services-appindexing:9.6.1” 然后添加编译'com.google.android.gms:play-services:9.6.0'

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

如果您想通过将此行添加到项目的“gradle-properties”来更改 JVM(Heapsize)的配置:

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

关于android - 添加 Google Play 服务后 "OutOfMemoryError: unable to create new native thread",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39676859/

相关文章:

android - 标签管理器类在 Play Services 8.1.0 中消失了吗?

android - java.lang.ClassNotFoundException 达尔维克系统.BaseDexClassLoader.findClass

Android WebView 屏幕在加载下一页或同一页时变黑

android - Phonegap/Android 中的 Materialise 图标不起作用

Android gms ImageManager 从不加载图像

android - 没有与此客户端 ID 关联的关联应用

android - 如何以编程方式在 Android 中使用 OpenGL ES 2.0 动态绘制虚线?

android - 返回我的 Activity 时如何显示 "close"Webview?

android - 如何取消应用程序与谷歌驱动器帐户的链接

android - Google Play 服务结果代码 = 10004