Android Studio error: failed to create Java virtual machine

I recently changed from JDK 1.7 to 1.8 to get com.android.support:recyclerview-v7:24.2.0for my application. It worked fine throughout the day, and from the next day he did not create the application properly, he threw this error when starting 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'
...........
..........
}
+4
source share
3 answers

this is how i solved it:

  • go to environment variables
  • in system variables:
  • New variable name: _JAVA_OPTIONS
  • New variable value: -Xmx512M

Restart android studio

+1
source

Perhaps this will help you.

→ → (Gradle - Android)

" VM" -Xmx512m -XX: MaxPermSize = 512

0

...

Invalid maximum heap size: -Xmx4g

The specified size exceeds the maximum displayed size.

Therefore, try to set javaMaxHeapSize to "1g" , because it depends on your maximum display size, which is set by your computer environment.

or

Just delete these lines

dexOptions {
incremental true
javaMaxHeapSize "4g"
}

Hope this helps you.

0
source

Source: https://habr.com/ru/post/1654657/


All Articles