Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-defaul
2022/6/2 23:24:13
本文主要是介绍Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-defaul,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
报错问题
代码中
原因:需要直接或者间接地依赖于版本 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
这篇关于Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-defaul的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-01为什么公共事业机构会偏爱 TiDB :TiDB 数据库在某省妇幼健康管理系统的应用
- 2024-04-26敏捷开发:想要快速交付就必须舍弃产品质量?
- 2024-04-26静态代码分析的这些好处,我竟然都不知道?
- 2024-04-26你在测试金字塔的哪一层?(下)
- 2024-04-26快刀斩乱麻,DevOps让代码评审也自动起来
- 2024-04-262024年最好用的10款ER图神器!
- 2024-04-2203-为啥大模型LLM还没能完全替代你?
- 2024-04-2101-大语言模型发展
- 2024-04-17基于SpringWeb MultipartFile文件上传、下载功能
- 2024-04-14个人开发者,Spring Boot 项目如何部署