Jetpack compose 更新到 1.0.0

编程入门 行业动态 更新时间:2024-10-21 12:35:04
本文介绍了Jetpack compose 更新到 1.0.0-rc01 后无法预览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

这仅在我更新到 1.0.0-rc01 时发生在我身上.它说:

this happened to me only when I updated to 1.0.0-rc01. it says:

找不到以下类:- androidxpose.ui.tooling.preview.ComposeViewAdapter(修复构建路径、编辑 XML、创建类)

The following classes could not be found: - androidxpose.ui.tooling.preview.ComposeViewAdapter (Fix Build Path, Edit XML, Create Class)

我的代码:

@Composable
@Preview
fun CenterProgress(){
    Box(
        modifier= Modifier.fillMaxSize(),
        contentAlignment = Alignment.Center
    ){
        CircularProgressIndicator(strokeWidth = 3.dp)
    }
}

推荐答案

更新:Android Studio Bumblebee 不再需要此内容 |2021.1.1 Canary 6Android Gradle 插件 7.1.0-alpha06.注意:Canary 4 已经修复了这个问题,但需要一个损坏的 AGP 版本.现在也解决了.

Update: This is no longer needed with Android Studio Bumblebee | 2021.1.1 Canary 6 and Android Gradle Plugin 7.1.0-alpha06. Note: Canary 4 already fixed this issue but required a broken version of AGP. This is now also resolved.

除了上面的答案:这里是如何在 gradle 中强制使用 ui-tooling 版本:

In addition to the above answers: here is how to force the ui-tooling version in gradle:

implementation("androidxpose.ui:ui-tooling:$compose_version") {
    version {
        // TODO: Remove this when Android Studio has become compatible again
        // Android Studio Bumblebee | 2021.1.1 Canary 3 is not compatible with module ui-tooling 1.0.0-rc01 or higher.
        // The Run Configuration for Composable Previews that Android Studio makes expects a PreviewActivity class
        // in the `androidxpose.ui.tooling.preview` package, but it was moved in 1.0.0-rc01, and thus causes error:
        // "androidxpose.ui.tooling.preview.PreviewActivity is not an Activity subclass or alias".
        // For more, see: https://stackoverflow/questions/68224361/jetpack-compose-cant-preview-after-updating-to-1-0-0-rc01
        strictly("1.0.0-beta09")
    }
}

这篇关于Jetpack compose 更新到 1.0.0-rc01 后无法预览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-23 02:41:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034420.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:新到   Jetpack   compose

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!