Jdk 1.8 For Android Studio

Technical docs‎ > ‎

Configuring Android Studio: IDE & VM Options, JDK, etc

This page is deprecated. Redirecting to https://developer.android.com/studio/intro/studio-config.html



You should not edit any files in the IDE installation directory. Instead, you can customize the attributes by creating your own .properties or .vmoptions files in the following directories. (This has been possible on some platforms before, but it required you to copy and change the entire contents of the files. With the latest changes these properties are now additive instead such that you can set just the attributes you care about, and the rest will use the defaults from the IDE installation).
Note: As of Android Studio 2.0, you can create/edit this file by accessing the 'Edit Custom VM Options' file from the Help menu.

Note: The folder name depends on the version of Android Studio. The documentation below applies to the release version (1.1.x), but if you are on a different version of Android Studio, see the table below for the correct folder name for your version.
The following table shows the configuration folder name to use for each studio version. This folder is referenced below as {FOLDER_NAME}
Android Studio Version
Preferences Folder Name
1.0.x and 1.1.x AndroidStudio
1.2.0 EAP/Preview AndroidStudioPreview1.2
1.2.0, 1.2.1, 1.2.2 AndroidStudio1.2
1.3 Preview AndroidStudioPreview1.3
1.3.0, 1.3.1, 1.3.2 AndroidStudio1.3
1.4.0 Preview AndroidStudioPreview1.4
1.4.0 AndroidStudio1.4
1.5.0, 1.5.1AndroidStudio1.5
2.0 Preview, Beta AndroidStudioPreview2.0
2.0 AndroidStudio2.0
2.1 PreviewAndroidStudioPreview2.1
2.1AndroidStudio2.1
2.2 Preview (Future)AndroidStudioPreview2.2
  • %USERPROFILE%.{FOLDER_NAME}studio.exe.vmoptions and/or%USERPROFILE%.{FOLDER_NAME}studio64.exe.vmoptions
  • %USERPROFILE%.{FOLDER_NAME}idea.properties
  • ~/Library/Preferences/{FOLDER_NAME}/studio.vmoptions
  • ~/Library/Preferences/{FOLDER_NAME}/idea.properties
  • ~/.{FOLDER_NAME}/studio.vmoptions and/or ~/.{FOLDER_NAME}/studio64.vmoptions
  • ~/.{FOLDER_NAME}/idea.properties
You can also place use environment variables to point to specific override files elsewhere:
  • STUDIO_VM_OPTIONS, which vmoptions file to use
  • STUDIO_PROPERTIES, which property file to use
  • STUDIO_JDK, which JDK to run studio with
Note that this last variable allows you to, for example, run Android Studio with the latest JDK version on OSX (which might otherwise pick a lower version specified in Info.plist):
$ open /Applications/Android Studio.app

(For Mac in particular, see this document on the topic of JDK selection.)

Increasing IDE Memory

By default, the IDE is assigned a maximum of 750 MB. If you have a large project, or if you have a lot of RAM on your system, the IDE will run better if you increase the amount of memory it is allowed to use. To do that, create your own studio.vmoptions override (in the location explained above) and add a line like this:

The full set of default JVM arguments are the following, in case you want to override any of the others (such as the start heap size of the MaxPermSize) :defaults in the IDE right

-Xms128m
-Xmx750m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=96m
-XX:+UseCompressedOops

Setting a Property

If you want to override an IDE property, create a new idea.properties file in your local config directory, where you specify just the override properties. This file will be merged with the default properties in the IDE. See the below list for various properties you can change.
For example, Android Studio 2.0 ships with experimental improved bidirectional text support (issue 182739). To enable this support, create a file named idea.properties with just this content:

On a Mac, for Android Studio 2.0 Preview, copy this file to ~/Library/Preferences/AndroidStudioPreview2.0/idea.properties.
On Windows, the path would be %USERPROFILE%.AndroidStudioPreview2.0idea.properties
On Linux, the path would be ~/.AndroidStudioPreview2.0/idea.properties
Help, I Already Edited the IDE Installation Files

If you've already edited the files by hand, here are the files from 1.0 such that you can restore them:

  • idea.properties (Windows)
  • studio.exe.vmoptions (Windows)
  • studio64.exe.vmoptions (Windows)
  • studio.vmoptions (Mac, Linux)
  • idea.properties (Mac, Linux)

Android Studio is Ignoring My idea.vmoptions File

Around 1.0 we switched from storing VM options in a file called idea.vmoptions to one called studio.vmoptions, to avoid clashing with IntelliJ installations. If you had created a file named idea.vmoptions for Studio, it will be ignored now. Put your edits in studio.vmoptions instead.

Properties

Here are properties you can customize in your own idea.properties file:
#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins folder. Make sure you're using forward slashes.
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Maximum file size (kilobytes) IDE should provide code assistance for.
# The larger file is the slower its editor works and higher overall system memory requirements are
# if code assistance is enabled. Remove this property or set to very large number if you need
# code assistance for any files available regardless their size.
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# This option controls console cyclic buffer: keeps the console output size not higher than the specified buffer size (Kb).
# Older lines are deleted. In order to disable cycle buffer use idea.cycle.buffer.size=disabled
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Configure if a special launcher should be used when running processes from within IDE.
# Using Launcher enables 'soft exit' and 'thread dump' features
#---------------------------------------------------------------------

#---------------------------------------------------------------------
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# There are two possible values of idea.popup.weight property: 'heavy' and 'medium'.
# If you have WM configured as 'Focus follows mouse with Auto Raise' then you have to
# set this property to 'medium'. It prevents problems with popup menus on some
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Use default anti-aliasing in system, i.e. override value of 'Settings|Editor|Appearance|Use anti-aliased font'
# option. May be useful when using Windows Remote Desktop Connection for instance.
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Disabling this property may lead to visual glitches like blinking and fail to repaint
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Removing this property may lead to editor performance degradation under Windows.
#---------------------------------------------------------------------

#---------------------------------------------------------------------
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Removing this property may lead to editor performance degradation under X Window.
#---------------------------------------------------------------------
#---------------------------------------------------------------------
# Workaround to avoid long hangs while accessing clipboard under Mac OS X.
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Maximum size (kilobytes) IDEA will load for showing past file contents -
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# High Density (aka Retina aka HiDPI) Display support:
# The two options below allow overriding the built-in HiDPI display detection
# The options are not supported on Mac, as Retina support is built-in.
# hidpi.system.dpi.override=<dpi_value>
# where <dpi_value> can range from 96 (100% zoom), to 288 (300%) zoom.
# hidpi=true is a legacy option that is equivalent to setting
#---------------------------------------------------------------------
#hidpi=true

idea.properties
mac-idea.properties
studio.exe.vmoptions
studio.vmoptions
studio64.exe.vmoptions

I can't compile a default new project for Android 2.1 because(?) the JDK used by Android Studio is JDK 1.7 but it should be JDK 1.6. To change it I go to File- Project Structure and try to find the JDK 1.6 location. But when I select its directory and press OK I get the following error: Please choose a valid JDK directory. Xamarin.Android uses the Java Development Kit (JDK) to integrate with the Android SDK for building Android apps and running the Android designer. The latest versions of the Android SDK (API 24 and higher) require JDK 8 (1.8) or the Microsoft Mobile OpenJDK Preview. Because the Android SDK tools available from Google are not yet compatible with.

Jdk 1.8 For Android Studio Download

Android Gradle plugin 3.0.0 and later support all Java 7 language features anda subset of Java 8 language features that vary by platform version. Whenbuilding your app using Android Gradle plugin 4.0.0 and higher, you can use anumber of Java 8 language APIs without requiring a minimum API level for yourapp.

Jdk 1.8 For Android Studio

This page describes the Java 8 language features you can use, how to properlyconfigure your project to use them, and any known issues you may encounter.Also see the following video for an overview.

  1. Install jdk 1.8 for android studio in windows 10/8.1/7 just in few step.
  2. Java SE Development Kit 8u291 Demos and Samples Downloads. Demos and samples of common tasks and new functionality available on JDK 8. JavaFX 8 demos and samples are included in the JDK 8 Demos and Samples packages. The source code provided with demos and samples for the JDK is meant to illustrate the usage of a given feature or technique.
  3. Java 8 language feature support (Android Gradle Plugin 3.0.0+) To start using supported Java 8 language features, update the Android plugin to 3.0.0 (or higher). After that, for each module that uses Java 8 language features (either in its source code or through dependencies), update the module's build.gradle file, as shown below: Groovy Kotlin.

Note: When developing apps for Android, using Java 8language features is optional. You can keep your project's source and targetcompatibility values set to Java 7, but you still need to compile using JDK 8.

The Android Gradle plugin provides built-in support for using certain Java 8language features and third-party libraries that use them. As shown in figure 1,the default toolchain implements the new language features by performingbytecode transformations, called desugar, as part of the D8/R8 compilationof class files into dex code.

Figure 1. Java 8 language feature support using desugar bytecode transformations.

Java 8 language feature support (Android Gradle Plugin 3.0.0+)

To start using supported Java 8 language features,update the Android pluginto 3.0.0 (or higher). After that, for each module that uses Java 8language features (either in its source code or through dependencies),update the module's build.gradle file, as shown below:

Jdk 8 For Android Studio

When building your app using Android Gradle plugin 3.0.0 and higher, the plugindoes not support all Java 8 language features. The following language featuresare now available on any API level:

Java 8 language featureNotes
Lambda expressionsNote that Android does not support the serialization of lambda expressions.
Method references
Type annotationsType annotation information is only available at compile time, and not at runtime. Also, the platform supports TYPE in API level 24 and below, but not ElementType.TYPE_USE or ElementType.TYPE_PARAMETER.
Default and static interface methods
Repeating annotations

In addition to the Java 8 language features above, plugin versions 3.0.0and later extend support fortry-with-resources to all Android API levels.

Desugar currently doesn't supportMethodHandle.invoke orMethodHandle.invokeExact.If your source code or one of your module dependencies use one of these methodsyou need to specify minSdkVersion 26 or higher. Otherwise, you get thefollowing error:

In some cases, your module may not be using the invoke or invokeExactmethods even when they're included in a library dependency. So, to keep usingthat library with minSdkVersion 25 or lower,enable code shrinking to removeunused methods. If that doesn't work, consider using an alternative library thatdoesn't use the unsupported methods.

Java 8+ language features desugaring that is available from Android GradlePlugin 3.0.0 does not make any additional classes and APIs (such asjava.util.stream.*) available for use on older Android releases. Support forpartial Java API desugaring is available from Android Gradle Plugin 4.0.0 orhigher and is described in the following section.

Java 8+ API desugaring support (Android Gradle Plugin 4.0.0+)

If you're building your app using Android Gradle plugin 4.0.0 or higher, theplugin extends support for using a number of Java 8 language APIs withoutrequiring a minimum API level for your app.

This additional support for older platform versions is possible because plugin4.0.0 and higher extend the desugaring engine to also desugar Java language APIs.So, you can include standard language APIs that were available only inrecent Android releases (such as java.util.streams) in apps that support olderversions of Android.

The following set of APIs are supported when building your app using AndroidGradle plugin 4.0.0 or higher:

  • Sequential streams (java.util.stream)
  • A subset of java.time
  • java.util.function
  • Recent additions to java.util.{Map,Collection,Comparator}
  • Optionals (java.util.Optional, java.util.OptionalInt andjava.util.OptionalDouble) and some other new classes useful with the aboveAPIs
  • Some additions to java.util.concurrent.atomic (new methods onAtomicInteger, AtomicLong and AtomicReference)
  • ConcurrentHashMap (with bug fixes for Android 5.0)

For a complete list of supported APIs, visitJava 8+ APIs available through desugaring.

Jdk 1.8 For Android Studio Download

To support these language APIs, the plugin compiles a separate DEX filethat contains an implementation of the missing APIs and includes it in your app.The desugaring process rewrites your app’s code to instead use this library atruntime.

To enable support for these language APIs on any version of the Android platform,update the Android pluginto 4.0.0 (or higher) and include the following in your app module’sbuild.gradle file:

Note that you may also need to include the above code snippet in a librarymodule's build.gradle file if:

Jdk 1.8 For Android Studio

  • The library module's instrumented tests use these language APIs (eitherdirectly or through the library module or its dependencies). This is so thatthe missing APIs are provided for your instrumented test APK.

  • You want to run lint on the library module in isolation. This is to helplint recognize valid usages of the language APIs and avoid reporting falsewarnings.

Resolved Jdk 1.8 Android Studio

Also note that API desugaring can be combined with shrinking, but onlywhen using the R8 shrinker.