4

I have recently changed the from JDK 1.7 to 1.8 for getting the com.android.support:recyclerview-v7:24.2.0 for my app. It worked fine for a day and from the next day it was not building the app properly it's throwing this error while running the project error take a look at my gradle.properties

org.gradle.jvmargs=-Xmx512m -XX:MaxPermSize=512m

build.gradle

buildscript {
repositories {
    maven { url 'https://maven.fabric.io/public' }
    jcenter()
    mavenCentral()
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.2"

defaultConfig {
    applicationId "XXXXXXX"
    minSdkVersion 14
    targetSdkVersion 23
    multiDexEnabled true
    versionCode 18
    versionName "XXXXX"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'),      'proguard-rules.pro'
    }
}
dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}
}

repositories {
    jcenter()
    maven { url 'https://maven.fabric.io/public' }
    mavenCentral()
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':mobihelp_sdk_android_v1.5.4')
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
    transitive = true;
}
compile('com.crashlytics.sdk.android:crashlytics-ndk:1.1.2@aar') {
    transitive = true;
}
compile files('libs/razorpay-android-0.13.0.jar')
compile 'com.android.support:design:24.2.0'
compile 'com.android.support:cardview-v7:24.2.0'
compile 'com.android.support:recyclerview-v7:24.2.0'
compile 'com.android.support:appcompat-v7:24.2.0'
...........
..........
}
Cedric Reichenbach
  • 8,970
  • 6
  • 54
  • 89
Spiker
  • 522
  • 4
  • 21

3 Answers3

1

this how I solved it :

  1. go to environment variables
  2. in system variables add :
  3. New Variable Name: _JAVA_OPTIONS
  4. New Variable Value: -Xmx512M

Restart Android studio

Amr Alaa
  • 1,156
  • 11
  • 16
0

Maybe it will help you.

File -> Settings -> Compiler (Gradle-based Android Projects)

Change the "VM options" to -Xmx512m -XX:MaxPermSize=512m

Cryperian
  • 116
  • 1
  • 8
0

In your log...

Invalid maximum heap size: -Xmx4g

The specified size exceeds the maximum representable size.

So try to set the value of javaMaxHeapSize "1g" because it's depends on your maximum representable size which is given by your computer environment.

Or

Just remove these lines

dexOptions {
incremental true
javaMaxHeapSize "4g"
}

Hope this will help you.

Vishal Chauhan
  • 932
  • 1
  • 6
  • 11