Is it possible to use Java 8 for Android development?

后端 未结 26 2034
礼貌的吻别
礼貌的吻别 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:03

    Add this config build.gradle and sync gradle:

    android {
        ...
        defaultConfig {
            ...
            jackOptions {
                enabled true
            }
        }
    
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
            // or
            //sourceCompatibility 1.8
            //targetCompatibility 1.8
        }
    }
    

提交回复
热议问题