我想使用Android Studio 4.0 Canary 3
正如在功能列表中提到的那样:
Android Studio 现在支持使用多种 Java 8 语言 API,而无需为您的应用设置最低 API 级别。
在模块的 build.gradle 文件中,将此coreLibraryDesugaringEnabled带有true参数的方法添加到compileOptions对象中。
像这样:
compileOptions {
// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
// Sets Java compatibility to Java 8
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Run Code Online (Sandbox Code Playgroud)
我预计它会正常工作,但会出现以下错误:
Could not find method coreLibraryDesugaringEnabled() for arguments [true] on object of type com.android.build.gradle.internal.CompileOptions.