1

I am trying to implement an ad network's SDK and it requires me to add Google Play Services.

Now when I add compile 'com.google.android.gms:play-services:9.6.0' to my gradle file I get an error (see bottom). This might be due to some other libraries already installed, but I can't figure out how to fix the files.

Project gradle:

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

Module 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'

The error:

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

As said: without the new line, it runs perfectly.

Code-Apprentice
  • 81,660
  • 23
  • 145
  • 268
yoeriboven
  • 3,541
  • 3
  • 25
  • 40
  • The problem seems to be on your development machine since you can't even compile. Did you see http://www.mastertheboss.com/jboss-server/jboss-monitoring/how-to-solve-javalangoutofmemoryerror-unable-to-create-new-native-thread to help diagnose the problem? – Code-Apprentice Sep 24 '16 at 13:46
  • Based from this [thread](https://plumbr.eu/outofmemoryerror/unable-to-create-new-native-thread), your error `java.lang.OutOfMemoryError: unable to create new native thread` is caused whenever the JVM asks for a new thread from the OS. Whenever the underlying OS cannot allocate a new native thread, this `OutOfMemoryError` will be thrown. Just check the link above to know the possible cause and solution for this problem. For more information, check this related [SO question](http://stackoverflow.com/questions/16789288/java-lang-outofmemoryerror-unable-to-create-new-native-thread). – KENdi Sep 28 '16 at 05:32

1 Answers1

1

because you add 'com.google.android.gms:play-services-appindexing:9.6.1' and then add compile 'com.google.android.gms:play-services:9.6.0'

if you don't need all the play-services just add what you need because that would produce a large apk file and some times OutOfMemoryError

if you want to change the configuration of the JVM (Heapsize) by adding this line to 'gradle-properties' of your project :

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Raafat Alhmidi
  • 1,106
  • 12
  • 18