No static method metafactory
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
.
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!
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
}
}
Try to refactor the Retrofit dependencies.
Write this:
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.2.0'