Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio 3.1 Default or static interface method used without --min-sdk-version >= 24

I have recently updated my Android Studio to 3.1 and I am starting receiving this error:

Default interface methods are only supported starting with Android N (--min-api 24): void android.arch.lifecycle.DefaultLifecycleObserver.a(android.arch.lifecycle.h) Message{kind=ERROR, text=Default interface methods are only supported starting with Android N (--min-api 24): void android.arch.lifecycle.DefaultLifecycleObserver.a(android.arch.lifecycle.h), sources=[Unknown source file], tool name=Optional.of(D8)}

Here is my app build.gradle file contents:

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 27
    defaultConfig {
        applicationId "com.sample"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 11
        versionName "2.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        multiDexEnabled true
    }

I am also using following Android Architecture Components:

implementation "android.arch.lifecycle:extensions:1.1.1"
implementation "android.arch.lifecycle:common-java8:1.1.1"
implementation "android.arch.persistence.room:runtime:1.0.0"
implementation "android.arch.persistence.room:rxjava2:1.0.0"
annotationProcessor "android.arch.persistence.room:compiler:1.0.0"

Besides this, I am also using Gradle build tools version 3.1.0 and Gradle version is 4.4.

After searching a bit on similar issue, I have also tried this in project gradle.properties without luck:

android.enableD8=true

Everything works fine in Android Studio 3.0, but as soon as I upgraded to 3.1 I started receiving this error.

like image 742
codelearner Avatar asked Apr 02 '18 17:04

codelearner


1 Answers

I think it may be a problem with their “special” implementation for Java 8 and min-apis. android.arch.lifecycle:common-java8:1.1.1.

Try the “normal” annotationProcessor android.arch.lifecycle:compiler:1.1.1.

I know it’s not the same, but it may expose a bug or a limitation of the library. Or perhaps your grade file has some old option?

My initial advice would be to create an EMPTY project with the same dependencies and see if you can make it work there.

It will make it easier to report to issues.google.com if needed.

Source: https://developer.android.com/topic/libraries/architecture/adding-components.html

like image 196
Martin Marconcini Avatar answered Nov 10 '22 15:11

Martin Marconcini