首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在android中由: java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses错误引起

在android中由: java.lang.NoClassDefFoundError: kotlin/reflect/full/KClasses错误引起
EN

Stack Overflow用户
提问于 2021-12-31 07:43:38
回答 2查看 616关注 0票数 1

试图运行一个新项目,但得到了这个错误

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

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

我的应用程序级build.gradle

代码语言:javascript
运行
复制
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")

}

项目级build.gradle

代码语言:javascript
运行
复制
  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
 }
EN

回答 2

Stack Overflow用户

发布于 2022-01-07 02:30:44

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

票数 0
EN

Stack Overflow用户

发布于 2022-01-11 05:47:20

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"

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70540098

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档