使用 Jetpack Compose UI 工具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
;它失败了:
java.lang.NoClassDefFoundError: Could not initialize class androidx.customview.poolingcontainer.PoolingContainer
at androidx.compose.ui.platform.ViewCompositionStrategy$DisposeOnDetachedFromWindowOrReleasedFromPool.installFor(ViewCompositionStrategy.android.kt:97)
...
真正的原因是别的:
java.lang.ClassNotFoundException: androidx.customview.poolingcontainer.R$id
at com.android.tools.idea.rendering.classloading.loaders.DelegatingClassLoader.findClass(DelegatingClassLoader.kt:81)
...
我怎样才能提供缺失的androidx.customview.poolingcontainer.R$id?
事实证明,在阅读源代码时,这需要customview-poolingcontainer
:
debugImplementation "androidx.customview:customview-poolingcontainer:1.0.0"
以为包含在customview
,但事实并非如此。这使得预览表现良好。
Here正在解释为什么会这样:
PoolingContainer 库
这增加了一个androidx.customview:customview-poolingcontainer
双方都依赖的神器Compose
and RecyclerView
, 通过这AbstractComposeView
and RecyclerView
发现对方并就何时进行沟通Compose
视图应该配置它的组成。
该机制独立于两者Compose
and RecyclerView
, 和
可用于任何回收容器或具有大量资源的儿童
在回收过程中应保留这些信息。
Relnote:“添加一个新的 PoolingContainer 库,允许监听
处理在视图之外管理其子级的容器的事件
等级制度。这稍后将作为依赖项添加Compose
and RecyclerView
"
错误:196371929
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)