• Inheritance from an interface with '@JvmDefault' members is only allowed with Xjvmdefault option


    报错问题

    代码中

    原因:需要直接或者间接地依赖于版本 2.5.0-alpha01

    在某些情况下,希望使用all-compatibility而不是all

    解决办法:

    在build.gradle的kotlinOptions中添加如下内容

    freeCompilerArgs += [
                    "-Xjvm-default=all",
            ]

     如图

     build.gradle 全部如下

    plugins {
        id 'com.android.application'
        id 'org.jetbrains.kotlin.android'
    }
    
    android {
        compileSdk 32
    
        defaultConfig {
            applicationId "com.example.smart"
            minSdk 21
            targetSdk 32
            versionCode 1
            versionName "1.0"
    
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            }
        }
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
        kotlinOptions {
            jvmTarget = '1.8'
            freeCompilerArgs += [
                    "-Xjvm-default=all",
            ]
        }
    
        buildFeatures {
            viewBinding true
            dataBinding true
        }
    }
    
    dependencies {
    
        implementation 'androidx.core:core-ktx:1.7.0'
        implementation 'androidx.appcompat:appcompat:1.3.0'
        implementation 'com.google.android.material:material:1.4.0'
        implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
        testImplementation 'junit:junit:4.13.2'
        androidTestImplementation 'androidx.test.ext:junit:1.1.3'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    
    
        //沉浸式状态栏 https://github.com/gyf-dev/ImmersionBar
        // 基础依赖包,必须要依赖
        implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2'
        // kotlin扩展(可选)
        implementation 'com.geyifeng.immersionbar:immersionbar-ktx:3.2.2'
        // fragment快速实现(可选)已废弃
        implementation 'com.geyifeng.immersionbar:immersionbar-components:3.2.2'
    
    
        // ViewModel
        implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.0-rc01")
        // ViewModel utilities for Compose
        implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.5.0-rc01")
        // LiveData
        implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.5.0-rc01")
        // Lifecycles only (without ViewModel or LiveData)
        implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.5.0-rc01")
    
        // Saved state module for ViewModel
        implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.0-rc01")
    
        // Annotation processor
        implementation("androidx.lifecycle:lifecycle-compiler:2.5.0-rc01")
        // alternately - if using Java8, use the following instead of lifecycle-compiler
        implementation("androidx.lifecycle:lifecycle-common-java8:2.5.0-rc01")
    
        implementation("androidx.activity:activity-ktx:1.4.0")
        def fragment_version = "1.4.1"
        implementation("androidx.fragment:fragment-ktx:$fragment_version")
    }
    

      

    参考于:https://blog.csdn.net/nicolelili1/article/details/124601441

  • 相关阅读:
    迪杰斯特拉(Dijkstra)算法描述及理解
    KMP初步
    网络流初步
    Cutting Codeforces Round #493 (Div. 2)
    优先队列小结
    树状数组初步理解
    分块思想
    树状数组-逆序对-HDU6318
    线段树
    8.12.5
  • 原文地址:https://www.cnblogs.com/changyiqiang/p/16338991.html
Copyright © 2020-2023  润新知