gpt4 book ai didi

android - 尝试 jetpack compose 时显示错误 : compiler backend and cannot be loaded by the old compiler

转载 作者:行者123 更新时间:2023-12-02 11:49:14 24 4
gpt4 key购买 nike

类 'androidx.compose.ui.platform.ComposeView' 由新的 Kotlin 编译器后端编译,旧编译器无法加载
这是我的 onCreate 方法:

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.fragment_delivered, container, false).apply {
findViewById<ComposeView>(R.id.compose_view).setContent {
MaterialTheme {
Surface {
Text("Hello")
}
}
}
}
}
编写版本:
accompanistVersion = "0.1.9"
composeVersion = '0.1.0-dev17'
应用程序.gradle
buildFeatures {
compose true
dataBinding true
}
composeOptions {
kotlinCompilerVersion rootProject.kotlinVersion
kotlinCompilerExtensionVersion rootProject.composeVersion
}



// Compose
implementation "androidx.compose.runtime:runtime:$rootProject.composeVersion"
implementation "androidx.compose.ui:ui:$rootProject.composeVersion"
implementation "androidx.compose.foundation:foundation:$rootProject.composeVersion"
implementation "androidx.compose.foundation:foundation-layout:$rootProject.composeVersion"
implementation "androidx.compose.material:material:$rootProject.composeVersion"
implementation "androidx.compose.ui:ui-viewbinding:$rootProject.composeVersion"
implementation "androidx.ui:ui-tooling:$rootProject.composeVersion"
implementation "androidx.compose.runtime:runtime-livedata:$rootProject.composeVersion"
implementation "com.google.android.material:compose-theme-adapter:$rootProject.composeVersion"
implementation "dev.chrisbanes.accompanist:accompanist-coil:$rootProject.accompanistVersion"

最佳答案

请将此任务添加到您的 app/build.gradle 文件中:

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += ["-Xallow-jvm-ir-dependencies", "-Xskip-prerelease-check"]
}
}

关于android - 尝试 jetpack compose 时显示错误 : compiler backend and cannot be loaded by the old compiler,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63619777/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com