Android Studio supports Java1.8 solutions _ tips

Source: Internet
Author: User

Java1.8 new features, such as support for lambda expressions, parent inference, etc., this article describes the new features of 1.8, interested students can point to see. However, since Androidstudio does not directly support Java1.8, we need to manually import some plug-ins to support 1.8:
First add plugins at the outermost layer of the app Build.gradle:

Apply plugin: ' Me.tatarka.retrolambda '

Then find the dependencies of the Build.gradle file and add the following code to this layer:

Retrolambdaconfig "net.orfjackal.retrolambda:retrolambda:${version number}"//According to the need to go to the official website view version number, the author is "2.3.0"

Then go to the Build.gradle in the project layer and find the dependencies layer and add the code:

Classpath ' me.tatarka:gradle-retrolambda:3.2.4 '

This will enable Java 1.8 Support, back to the app layer in the Build.gradle, under the Android–>defaultconfig layer to add the compilation settings can:

compileoptions {
        sourcecompatibility javaversion.version_1_8
        targetcompatibility JavaVersion.VERSION_1_8
    }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.