Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Jack (Java Android Compiler Kit) in android studio

I am updated my androidstudio 2.1 stable.As per Android Studio 2.1 supports Android N Developer Preview Android studio 2.1 support Jack (Java Android Compiler Kit) compiler .

How to add or use Jack in android studio?

NOTE:

The Jack toolchain is deprecated, as per Java 8 Language Feature Support on Android. However, you may continue to use it to enable Java 8 language features until the replacement is available.

As of this March 14, 2017 announcement, the Jack toolchain is deprecated. Jack was the default Android build toolchain for Android 6.0–8.1.

https://source.android.com/source/jack

like image 847
pRaNaY Avatar asked Apr 27 '16 04:04

pRaNaY


People also ask

What is Jack SERVER in Android?

Jack is an Android toolchain that compiled Java source into Android dex bytecode. You don't have to do anything differently to use Jack—just use your standard makefile commands to compile the tree or your project. Android 8.1 is the last release that uses Jack.

Is Java supported in Android Studio?

Android Gradle plugin 3.0. 0 and later support all Java 7 language features and a subset of Java 8 language features that vary by platform version.

What is Jack compiler?

The Jack Compiler translates files written in the Jack programming language into Virtual Machine code. For each source . jack file, the compiler creates a corresponding . vm file, and stores the translated code in it.


3 Answers

The details on what is required to use Jack and how can be found in the documentation.

Here is the relevant part from the docs that goes in build.gradle on how to use jackOptions and set the compileOptions for java 1.8.

android {
    ...
    defaultConfig {
        ...
        jackOptions {
            enabled true
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

UPDATE

The Jack toolchain is now considered deprecated according to this post and work is being done to natively support Java 8 features as part of the Android build system in the coming weeks according to the post.

The post also mentions that there should be little to no work migrating from Jack to the new method in case you still wanted to try enabling Java 8 features with Jack.

UPDATE 2 Preview Built-in Support

You can now try out the new built-in support for Java 8 using the latest Android Studio preview 2.4 preview 6.

For more information on how to enable it or migrate from Jack or Retrolambda see the documentation.

like image 124
George Mulligan Avatar answered Nov 20 '22 04:11

George Mulligan


You can enable jack compiler by adding following line in build.gradle file.

android{

compileSdkVersion 23

buildToolsVersion "24rc2"

defaultConfig {
    ...
    jackOptions {
        enabled true
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}}
like image 24
Raghav Thakkar Avatar answered Nov 20 '22 04:11

Raghav Thakkar


Jack/Jill will be abandoned in the near future, see the Google post. https://android-developers.googleblog.com/2017/03/future-of-java-8-language-feature.html

like image 23
mingyuan-xia Avatar answered Nov 20 '22 04:11

mingyuan-xia