Is it possible to use Java 8 for Android development?

后端 未结 26 2344
礼貌的吻别
礼貌的吻别 2020-11-21 22:50

Searching the web, it is not clear if Java 8 is supported for Android development or not.

Before I download/setup Java 8, can some one point me at any \"official\" d

26条回答
  •  不要未来只要你来
    2020-11-21 23:02

    Adding the following fixed the problem for me (Android studio 2.3.2):

    build.gradle (Project)

    buildscript {
    repositories {
        ...
        jcenter()
    }
    dependencies {
        ...
        classpath 'me.tatarka:gradle-retrolambda:3.4.0' // DEPENDENCY
        ...
       }
    }
    

    build.gradle (Module: app)

    apply plugin: 'com.android.application'
    apply plugin: 'me.tatarka.retrolambda' //PLUGIN
    
    android {
        ...
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        } // SET JAVA VERSION
        ...
    }
    

提交回复
热议问题