geting的原因是:java.lang.NoClassDefFoundError:kotlin/reflect/ful



试图运行新项目,但收到此错误

引起原因:java.lang.NoClassDefFoundError:kotlin/reflect/full/KClasses

我已尝试添加反射依赖项,但不起作用我也添加了依赖项,但仍然无法解决问题

我的应用程序级别构建.gradle

plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.sdd.calender"
minSdk 21
targetSdk 31
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'
}
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso- 
core:3.4.0'
implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.10")
}

项目级建筑.gradle

buildscript {
ext.kotlin_version = "1.5.21"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.4"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"    
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

您将反射依赖项添加到了项目级别的gradle文件,而不是应用程序级别的文件。请尝试将implementation行移到该文件中。

implementation("org.jetbrains.kotlin:kotlin-reflect:1.6.10")替换为implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

最新更新