0

enter image description here

(Actually, I thought I had updated to Bumblebee, but I get a notification like the image.)

A few days ago, I ran Android Studio as usual and proceeded with the update according to the update notification.

But when I try to build today, it doesn't work at all.

At first I got this problem and in gradle I modified the nav_version like the solution in the link.

but after rebuild I got the following error:

Dependency 'androidx.navigation:navigation-ui-ktx:2.5.0-alpha01' requires 'compileSdkVersion' to be set to 31 or higher.
Compilation target for module ':app' is 'android-30'

After that, I modified gradle :app as following.

Changed sdkversion and targetsdkversion to 31.

android {
    compileSdkVersion 31
    buildToolsVersion "30.0.3"
    defaultConfig {
        minSdkVersion 24
        targetSdkVersion 31
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

But it still doesn't work and this problem occurs again in the ViewModelFactory class.

Inheritance from an interface with jvmdefault members is only allowed with option

I thought it was updated to Bumblebee, but it doesn't seem to have been updated and it doesn't even build, which is embarrassing.

ybybyb
  • 1,385
  • 1
  • 12
  • 33
  • 1
    Does this answer your question? [Error Message I cant resolve: "Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-default option"](https://stackoverflow.com/questions/70992947/error-message-i-cant-resolve-inheritance-from-an-interface-with-jvmdefault) – Mark Feb 05 '22 at 22:06
  • I'm sorry, but I copied it as it is and tried it in the `build.gradle` of the `app` unit or the `build.gradle` of the `project` unit, but another error occurs again. – ybybyb Feb 07 '22 at 18:09
  • Your build tools are slightly out of date. It's usual to update both build tools with target/compile SDK upgrades. This might be a possible cause. – dniHze Feb 10 '22 at 22:20

1 Answers1

4

I've run into the same thing and I looked at the same questions and the answers were not specific enough or didn't work. I ended up trying this in my app level build.gradle.

kotlinOptions {
    freeCompilerArgs = ['-Xjvm-default=compatibility']
}

More specifically to my project, my kotlinOptions look like this:

kotlinOptions {
        jvmTarget = '1.8'
        freeCompilerArgs = ['-Xjvm-default=compatibility']
    }

This is where I found it. @JvmDefault and how add compiler option

This was an answer I found that didn't work for me but it was the answer to my specific question and explained the problem with more depth. https://stackoverflow.com/a/70993001/5705252

DarkOhms
  • 90
  • 10
  • Thanks for highlighting the solution. It worked for me after adding freeCompilerArgs = ['-Xjvm-default=compatibility'] in the module.gradle file. During my study, I noticed the issue happened when I tried to create a class in new project that implements ViewModelFactory.Provider Interface but when I opened the existing project having the similar code piece I did see all working as expected without adding freeCompilerArgs = ['-Xjvm-default=compatibility'] in the module.gradle file. Not sure what is the reason. I may bring it here in case of finding it. – Nandagopal T Mar 11 '22 at 07:08