Mar*_*ler 8 dependencies android android-studio androidx android-jetpack-compose
使用 Jetpack Compose UI 工具1.2.0-rc01
和 Compose 编译器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
}
Run Code Online (Sandbox Code Playgroud)
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)
...
Run Code Online (Sandbox Code Playgroud)
真正的原因是别的:
java.lang.ClassNotFoundException: androidx.customview.poolingcontainer.R$id
at com.android.tools.idea.rendering.classloading.loaders.DelegatingClassLoader.findClass(DelegatingClassLoader.kt:81)
...
Run Code Online (Sandbox Code Playgroud)
我怎样才能提供失踪的物品androidx.customview.poolingcontainer.R$id
?
Mar*_*ler 14
阅读源代码后发现,这需要customview-poolingcontainer
:
debugImplementation "androidx.customview:customview-poolingcontainer:1.0.0"
Run Code Online (Sandbox Code Playgroud)
以为它包含在 中customview
,但事实并非如此。这使得预览表现良好。
这里正在解释为什么会这样:
PoolingContainer 库
这添加了androidx.customview:customview-poolingcontainer
和 都依赖的工件,通过它和Compose
相互发现并就视图何时应处置其组合进行通信。 该机制独立于和,并且可用于任何回收容器或具有应在回收过程中保留的大量资源的子容器。 Relnote:“添加一个新的 PoolingContainer 库,该库允许侦听在 View 层次结构之外管理其子级的容器的处置事件。这将在稍后添加为和 的依赖项” Bug:196371929RecyclerView
AbstractComposeView
RecyclerView
Compose
Compose
RecyclerView
Compose
RecyclerView
归档时间: |
|
查看次数: |
2280 次 |
最近记录: |