2016-09-24 72 views
1

我正在嘗試實施廣告網絡的SDK,並且需要我添加Google Play服務。添加Google Play服務後出現「OutOfMemoryError:無法創建新本機線程」

現在,當我將compile 'com.google.android.gms:play-services:9.6.0'添加到我的gradle文件時,出現錯誤(請參見下方)。這可能是由於已經安裝了一些其他庫,但我無法弄清楚如何修復這些文件。

的gradle項目:

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

模塊的gradle:

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

作爲表示:沒有新的線,它完美地運行。

+0

問題se因爲你甚至不能編譯,所以ems會在你的開發機器上。您是否看到http://www.mastertheboss.com/jboss-server/jboss-monitoring/how-to-solve-javalangoutofmemoryerror-unable-to-create-new-native-thread來幫助診斷問題? –

+0

基於此[線程](https://plumbr.eu/outofmemoryerror/unable-to-create-new-native-thread),您的錯誤'java.lang.OutOfMemoryError:無法創建新的本地線程'是每當JVM從操作系統請求一個新的線程。只要底層操作系統無法分配新的本地線程,就會拋出此「OutOfMemoryError」。只需檢查上面的鏈接,瞭解此問題的可能原因和解決方案。有關更多信息,請查看相關的[SO問題](http://stackoverflow.com/questions/16789288/java-lang-outofmemoryerror-unable-to-create-new-native-thread)。 – KENdi

回答

1

,因爲你加 'com.google.android.gms:發揮服務-appindexing:9.6.1' 然後添加編譯 'com.google.android.gms:發揮服務:9.6.0'

如果你並不需要所有的播放服務,只需添加你所需要的,因爲如果你想加入這個改變JVM(HEAPSIZE)的配置,將產生較大的apk文件和一些時間的OutOfMemoryError

line to'gradle-properties'of your project:

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

評論appindexing行並將其他行添加到cradle-properties都不會更改任何內容。 – yoeriboven

+0

嘗試使用'play-services:9:0:2' 這對我很有用 –

相關問題