首页 > 其他分享> > Inheritance from an interface with '@JvmDefault' members is only allowed with -Xjvm-defaul
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
标签:option,androidx,default,Inheritance,implementation,rc01,com,lifecycle,2.5 来源: https://www.cnblogs.com/changyiqiang/p/16338991.html