I want to use Android Studio 4.0 Canary 3
as in the, features list has mentioned:
Android Studio now includes support for using a number of Java 8 language APIs without requiring a minimum API level for your app.
with adding this method coreLibraryDesugaringEnabled
with a true
argument into the compileOptions
object, in the module’s build.gradle file.
like this:
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
}
I expected it would work fine, but it makes the below error:
Could not find method coreLibraryDesugaringEnabled() for arguments [true] on object of type com.android.build.gradle.internal.CompileOptions.
Answer from dankawka on https://github.com/juliuscanute/qr_code_scanner/issues/325, read to make sure your problem is actually the same.
You have to upgrade Gradle, Kotlin and Kotlin Gradle Plugin:
ext.kotlin_version = '1.3.50'
to ext.kotlin_version = '1.5.10'
classpath 'com.android.tools.build:gradle:3.5.0'
to classpath 'com.android.tools.build:gradle:4.2.0'
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
to distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
What about if you use isCoreLibraryDesugaringEnabled
?
You should use latest Gradle service version > 6.3 (Gradle wrapper file) and Gradle build version > 4.1.0 alpha (app.gradle file) in order to work desugaring.
Here build.gradle screenshot as described at Google guide
use this in build.gradle:
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
}
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With