Jetpack Compose 设置问题:无法加载类“org.jetbrains.kotlin.gradle.tasks.KotlinCompile”
2020-12-24
2856
我有一个新的 Android 项目,我想使用 Jetpack Compose,但按照 此处概述 的步骤操作后,出现了以下构建错误:
Unable to load class 'org.jetbrains.kotlin.gradle.tasks.KotlinCompile'.
This is an unexpected error. Please file a bug containing the idea.log file.
也许我使用 Kotlin DSL build.gradle.kts 使问题更加复杂,但这是我的 gradle 设置:
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-kapt")
id("dagger.hilt.android.plugin")
}
android {
compileSdkVersion(30)
defaultConfig {
applicationId = "..."
minSdkVersion(24)
targetSdkVersion(30)
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
}
compileOptions {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
}
buildFeatures {
dataBinding = true
compose = true
}
kotlinOptions {
jvmTarget = "1.8"
useIR = true
}
composeOptions {
kotlinCompilerVersion = "1.4.20"
kotlinCompilerExtensionVersion = "1.0.0-alpha08"
}
}
dependencies {
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
//...
}
1个回答
尝试使用 '1.0.0-alpha09' 和 Kotlin 版本“1.4.21”,您就可以开始了。
您的构建脚本中有这个吗?
buildscript {
ext {
compose_version = '1.0.0-alpha09'
}
ext.kotlin_version = "1.4.21"
Code Poet
2020-12-24