No static method metafactory
Solution 1:
Try to switch to Java 8 compatibility mode, for proper de-sugaring of some library:
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
}
Besides, Google JSON API might rather need the GsonConverterFactory
.
Solution 2:
You can resolve this error by setting compileOptions
in build.gradle
(app) file.
android {
...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
Solution 3:
In my case, it was not for retrofit. I was using a local library module (named Android XML to PDF generator) that was using Java version 1.8
(for using Rx Java), but my app level Java version
was less than 1.8
.
So I simply added in the following lines in my app level build.gradle -
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Then it worked for me!