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.

2
  • The problem seems to be on your development machine since you can't even compile. Did you see mastertheboss.com/jboss-server/jboss-monitoring/… to help diagnose the problem? Commented Sep 24, 2016 at 13:46
  • Based from this 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. Commented Sep 28, 2016 at 5:32

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Commenting the appindexing line and adding the other line to cradle-properties both don't change anything.
try to use 'play-services:9:0:2' that's worked for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.