0

My code is running fine on device but when i try to generate Signed APK, it starts giving error;

Information:Gradle tasks [:assembleRelease]
Error:UNEXPECTED TOP-LEVEL ERROR:
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:Execution failed for task ':transformClassesWithDexForRelease'.
> com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException: 
java.lang.UnsupportedOperationException
Information:BUILD FAILED

In my Gradle file the only thing which is causing problem is this line, if i remove this line it will generate the signed APK.

compile 'com.google.android.gms:play-services:9.6.1'

Here is my Gradle file;

buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.1'
}
}

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
defaultConfig {
    minSdkVersion 15
    targetSdkVersion 23
    versionCode = 2
    versionName = "1.0.2"
    multiDexEnabled true
}
sourceSets {
    main {
        manifest.srcFile 'AndroidManifest.xml'
        java.srcDirs = ['src']
        resources.srcDirs = ['src']
        aidl.srcDirs = ['src']
        renderscript.srcDirs = ['src']
        res.srcDirs = ['res']
        assets.srcDirs = ['assets']
        jniLibs.srcDirs = ['libs']
        jni.srcDirs = []
    }

    instrumentTest.setRoot('tests')
}

signingConfigs {
    release
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}
}


// ~/.gradle/gradle.properties 
if (project.hasProperty('keystoreFile') &&
    project.hasProperty('keystorePassword') &&
    project.hasProperty('keystoreAliasPassword')) {
android.signingConfigs.release.storeFile = file(keystoreFile)
android.signingConfigs.release.storePassword = keystorePassword
android.signingConfigs.release.keyPassword = keystoreAliasPassword
android.signingConfigs.release.keyAlias = keystoreAlias
} else {
android.buildTypes.release.signingConfig = null
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services:9.6.1'
}

And these are the libraries i have in lib folder of my project; enter image description here

4

2 回答 2

1

There's a separate way to raise the heap limit of the dexing operation. Add this to your android closure in your build.gradle file:

    dexOptions {
         javaMaxHeapSize "4g"
    }

and see if that helps.

于 2016-10-13T12:50:37.433 回答
0

Try to, Add this line at the end of your Project gradle file.

apply plugin: 'com.google.gms.google-services'

and add classpath dependencies in your Module gradle

 dependencies {
        classpath 'com.android.tools.build:gradle:2.2.1'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
于 2016-10-13T12:48:16.467 回答