title: Flutter error in Android Studio (Windows): Unrecognized option: --add-opens
body: <p>I have been working on a Flutter application that I've successfully run on both an Android emulator and a physical device during the past couple of weeks. Somehow and all of a sudden, I'm unable to run it in debug mode.
  I tried several answers found in SO but they all seem to be hacks that don't really fix the issue.</p>
  <h3>The Error</h3>
  <p>When I tried to run the application, an error is thrown from Gradle daemon because it could not create a JVM as seen in the screenshot below...</p>
  <p><a href="https://i.stack.imgur.com/yn31p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yn31p.png" alt="enter image description here" /></a></p>
  <pre><code>Error: Could not create the Java Virtual Machine.
  Error: A fatal exception has occurred. Program will exit.
  Unrecognized option: --add-opens
  </code></pre>
  <h3>Possible cause???</h3>
  <p>I remember I upgraded the Gradle Plugin to I-don't-know-what-version, I wasn't really paying attention to it (my bad) but I kept on working without any issues. Then, I upgrade Flutter to version 2.2.2, that's when the issue started to creeping in (Maybe).</p>
  <h3>Supporting Info</h3>
  <p>OS: Windows Server 2016 Standard (x64)<br />
  IDE: Android Studio Artic Fox 2020.3.1<br />
  Flutter Version: 2.2.2<br />
  JAVA_HOME: Pointing to JDK 1.8</p>
  <p>Project Structure -&gt; Project Settings -&gt; Project</p>
  <p><a href="https://i.stack.imgur.com/UW5AG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UW5AG.png" alt="enter image description here" /></a></p>
  <p>Java version...</p>
  <p><a href="https://i.stack.imgur.com/ezTTa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ezTTa.png" alt="enter image description here" /></a></p>
  <p>Flutter doctor output...</p>
  <p><a href="https://i.stack.imgur.com/XrbJE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XrbJE.png" alt="enter image description here" /></a></p>
  <h3>Gradle files</h3>
  <p>android/build.gradle</p>
  <pre><code>buildscript {
      ext.kotlin_version = '1.3.50'
      repositories {
          google()
          jcenter()
      }
  
      dependencies {
          classpath 'com.android.tools.build:gradle:4.1.0'
          classpath &quot;org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version&quot;
      }
  }
  
  allprojects {
      repositories {
          google()
          jcenter()
      }
  }
  
  rootProject.buildDir = '../build'
  subprojects {
      project.buildDir = &quot;${rootProject.buildDir}/${project.name}&quot;
      project.evaluationDependsOn(':app')
  }
  
  task clean(type: Delete) {
      delete rootProject.buildDir
  }
  
  </code></pre>
  <p>app/build.gradle</p>
  <pre><code>def localProperties = new Properties()
  def localPropertiesFile = rootProject.file('local.properties')
  if (localPropertiesFile.exists()) {
      localPropertiesFile.withReader('UTF-8') { reader -&gt;
          localProperties.load(reader)
      }
  }
  
  def flutterRoot = localProperties.getProperty('flutter.sdk')
  if (flutterRoot == null) {
      throw new GradleException(&quot;Flutter SDK not found. Define location with flutter.sdk in the local.properties file.&quot;)
  }
  
  def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
  if (flutterVersionCode == null) {
      flutterVersionCode = '1'
  }
  
  def flutterVersionName = localProperties.getProperty('flutter.versionName')
  if (flutterVersionName == null) {
      flutterVersionName = '1.0'
  }
  
  apply plugin: 'com.android.application'
  apply plugin: 'kotlin-android'
  apply from: &quot;$flutterRoot/packages/flutter_tools/gradle/flutter.gradle&quot;
  
  android {
      compileSdkVersion 30
  
      sourceSets {
          main.java.srcDirs += 'src/main/kotlin'
      }
  
      defaultConfig {
          // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
          applicationId &quot;com.domain.app_name&quot;
          minSdkVersion 16
          targetSdkVersion 30
          versionCode flutterVersionCode.toInteger()
          versionName flutterVersionName
      }
  
      buildTypes {
          release {
              // TODO: Add your own signing config for the release build.
              // Signing with the debug keys for now, so `flutter run --release` works.
              signingConfig signingConfigs.debug
          }
      }
  }
  
  flutter {
      source '../..'
  }
  
  dependencies {
      implementation &quot;org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version&quot;
  }
  
  </code></pre>
  <h3>Question</h3>
  <p><strong>Is there an obvious fix to the error?</strong><br />
  I haven't worked on Android for about 2 years since I started this project so it might be possible that my problem is quite obvious.
  I might be missing something here but if I am, please let me know and I'll update the answer.</p>