代码生成期间的异常 Jetpack Compose [英] Exception during code generation Jetpack Compose

查看:27
本文介绍了代码生成期间的异常 Jetpack Compose的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是尝试使用 val context =ambient(ContextAmbient) 从我的资源中加载图像,但是当我尝试运行该项目时,在生成代码的过程中出现错误.

I just tried to load an image from my resources with val context = ambient(ContextAmbient) but when I try to run the project I get an error during the generation of the code.

java.lang.IllegalStateException:后端内部错误:代码生成过程中出现异常

java.lang.IllegalStateException: Backend Internal error: Exception during code generation

@Composable
fun MovieImage(image: Int) {
    val context = ambient(ContextAmbient)
    Container(modifier = Modifier.None, width = 24.dp, height = 24.dp) {
        DrawImage(image = imageFromResource( context.resources, image))
    }
}

推荐答案

我在从 0.1.0-dev03 升级到 0.1.0-dev05 时遇到了同样的问题代码>.通过将 composeOptions{ kotlinCompilerExtensionVersion "0.1.0-dev05" } 添加到我的 build.gradle 中解决了这个问题:

I ran in to the same problem when upgrading from 0.1.0-dev03 to 0.1.0-dev05. It was solved by adding composeOptions{ kotlinCompilerExtensionVersion "0.1.0-dev05" } to my build.gradle like this:

android {
    // ... other gradle properties

    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion "0.1.0-dev05"
    }
}

这篇关于代码生成期间的异常 Jetpack Compose的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆