NoclassDeffoundError:无法初始化类androidx.customview.poolingcontainer.poolingcontainer

发布于 2025-02-11 15:35:37 字数 1156 浏览 1 评论 0原文

使用JetPack组合UI Tooling 1.2.0-RC01并组合编译器1.2.0;

android {
    composeOptions {
        kotlinCompilerExtensionVersion "1.2.0"
    }
}
dependencies {
    debugImplementation "androidx.compose.ui:ui-tooling:1.2.0-rc01"
    debugImplementation "androidx.customview:customview:1.1.0" // being pulled in by another dependency
    debugImplementation "androidx.customview:customview:1.2.0-alpha01" // also tried the latest version
}

IDE无法显示@preview; it fails with:

java.lang.NoClassDefFoundError: Could not initialize class androidx.customview.poolingcontainer.PoolingContainer
    at androidx.compose.ui.platform.ViewCompositionStrategy$DisposeOnDetachedFromWindowOrReleasedFromPool.installFor(ViewCompositionStrategy.android.kt:97)
    ...

The actual cause is something else:

java.lang.ClassNotFoundException: androidx.customview.poolingcontainer.R$id
    at com.android.tools.idea.rendering.classloading.loaders.DelegatingClassLoader.findClass(DelegatingClassLoader.kt:81)
    ...

How can I provide the missing

With Jetpack Compose UI Tooling 1.2.0-rc01 and Compose Compiler 1.2.0;

android {
    composeOptions {
        kotlinCompilerExtensionVersion "1.2.0"
    }
}
dependencies {
    debugImplementation "androidx.compose.ui:ui-tooling:1.2.0-rc01"
    debugImplementation "androidx.customview:customview:1.1.0" // being pulled in by another dependency
    debugImplementation "androidx.customview:customview:1.2.0-alpha01" // also tried the latest version
}

The IDE cannot display the @Preview; it fails with:

java.lang.NoClassDefFoundError: Could not initialize class androidx.customview.poolingcontainer.PoolingContainer
    at androidx.compose.ui.platform.ViewCompositionStrategy$DisposeOnDetachedFromWindowOrReleasedFromPool.installFor(ViewCompositionStrategy.android.kt:97)
    ...

The actual cause is something else:

java.lang.ClassNotFoundException: androidx.customview.poolingcontainer.R$id
    at com.android.tools.idea.rendering.classloading.loaders.DelegatingClassLoader.findClass(DelegatingClassLoader.kt:81)
    ...

How can I provide the missing androidx.customview.poolingcontainer.R$id?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

偏闹i 2025-02-18 15:35:37

当读取来源时,事实证明,这需要customview-poolingContainer

debugImplementation "androidx.customview:customview-poolingcontainer:1.0.0"

以为它包含在customview中,但事实并非如此。这使得预览表现。


poolingContainer库

这添加了androidx.customView:customView-poolingContainer trifact,它依赖于compose> compose and recyclerviewAbstract> Appact> AbstractComposeView 和recyclerview互相发现,并交流构成视图应处置其构图。

该机制独立于composerecyclerview,以及
可以用于具有大资源的任何回收容器或孩子
应该在回收中保留。

remnote:“添加一个允许聆听的新的PiomingContainer库
处置一个容器的事件,该容器在视图之外管理其子女
等级制度。稍后将添加为composerecyclerview的依赖项“

错误:196371929


As it turned out when reading the sources, this needs the customview-poolingcontainer:

debugImplementation "androidx.customview:customview-poolingcontainer:1.0.0"

Thought it was included in customview, but it's not. This makes the preview behave.


Here it is being explained why it's like that:

PoolingContainer library

This adds an androidx.customview:customview-poolingcontainer artifact that is depended on by both Compose and RecyclerView, through which AbstractComposeView and RecyclerView discover each other and communicate about when the Compose view should dispose its composition.

This mechanism is independent of both Compose and RecyclerView, and
could be used for any recycling container or child with heavy resources
that should be retained across recycling.

Relnote: "Add a new PoolingContainer library that allows for listening
to dispose events of a container that manages its children outside the View
hierarchy. This will later be added as a dependency of Compose and RecyclerView"

Bug: 196371929

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文