JakeWharton / ThreeTenABP

An adaptation of the JSR-310 backport for Android.
Apache License 2.0
3.55k stars 132 forks source link

Support Compose Preview #133

Closed thegarlynch closed 3 years ago

thegarlynch commented 3 years ago

Right now there is this error, coming up everytime i use it

org.threeten.bp.zone.ZoneRulesException: No time-zone data files registered at org.threeten.bp.zone.ZoneRulesProvider.getProvider(ZoneRulesProvider.java:165) at org.threeten.bp.zone.ZoneRulesProvider.getRules(ZoneRulesProvider.java:122) at org.threeten.bp.ZoneRegion.ofId(ZoneRegion.java:143) at org.threeten.bp.ZoneId.of(ZoneId.java:358) at org.threeten.bp.ZoneId.of(ZoneId.java:286) at org.threeten.bp.ZoneId.systemDefault(ZoneId.java:245) at org.threeten.bp.Clock.systemDefaultZone(Clock.java:137) at org.threeten.bp.ZonedDateTime.now(ZonedDateTime.java:168) at com.cpssoft.mobile.titan.common.extentions.DateExtensionsKt.convertTime(DateExtensions.kt:21) at com.cpssoft.mobile.titan.pos.view.report.landscape.list.ReportItemKt.ReportItem(ReportItem.kt:169) at com.cpssoft.mobile.titan.pos.view.report.landscape.list.ReportItemListKt$PreviewReportItemList$3.invoke(ReportItemList.kt:64) at com.cpssoft.mobile.titan.pos.view.report.landscape.list.ReportItemListKt$PreviewReportItemList$3.invoke(ReportItemList.kt:62) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at com.cpssoft.mobile.titan.pos.view.report.landscape.list.ReportItemListKt$ReportItemList$2.invoke(ReportItemList.kt:46) at com.cpssoft.mobile.titan.pos.view.report.landscape.list.ReportItemListKt$ReportItemList$2.invoke(ReportItemList.kt:44) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:116) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.material.ScaffoldKt$ScaffoldLayout$1$1$1$bodyContentPlaceables$1.invoke(Scaffold.kt:316) at androidx.compose.material.ScaffoldKt$ScaffoldLayout$1$1$1$bodyContentPlaceables$1.invoke(Scaffold.kt:314) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.ui.layout.SubcomposeLayoutState$subcompose$2$1$1.invoke(SubcomposeLayout.kt:241) at androidx.compose.ui.layout.SubcomposeLayoutState$subcompose$2$1$1.invoke(SubcomposeLayout.kt:241) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:107) at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:34) at androidx.compose.runtime.ComposerKt.invokeComposable(Composer.kt:3330) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2577) at androidx.compose.runtime.ComposerImpl$doCompose$2$5.invoke(Composer.kt:2573) at androidx.compose.runtime.SnapshotStateKt.observeDerivedStateRecalculations(SnapshotState.kt:540) at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:2566) at androidx.compose.runtime.ComposerImpl.composeContent$runtime_release(Composer.kt:2517) at androidx.compose.runtime.CompositionImpl.composeContent(Composition.kt:476) at androidx.compose.runtime.Recomposer.composeInitial$runtime_release(Recomposer.kt:727) at androidx.compose.runtime.ComposerImpl$CompositionContextImpl.composeInitial$runtime_release(Composer.kt:2980) at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:432) at androidx.compose.ui.layout.SubcomposeLayoutState.subcomposeInto(SubcomposeLayout.kt:259) at androidx.compose.ui.layout.SubcomposeLayoutState.access$subcomposeInto(SubcomposeLayout.kt:145) at androidx.compose.ui.layout.SubcomposeLayoutState$subcompose$2.invoke(SubcomposeLayout.kt:234) at androidx.compose.ui.layout.SubcomposeLayoutState$subcompose$2.invoke(SubcomposeLayout.kt:231) at androidx.compose.runtime.snapshots.SnapshotStateObserver.withNoObservations(SnapshotStateObserver.kt:144) at androidx.compose.ui.node.OwnerSnapshotObserver.withNoSnapshotReadObservation$ui_release(OwnerSnapshotObserver.kt:49) at androidx.compose.ui.node.LayoutNode.withNoSnapshotReadObservation$ui_release(LayoutNode.kt:1107) at androidx.compose.ui.layout.SubcomposeLayoutState.subcompose(SubcomposeLayout.kt:231) at androidx.compose.ui.layout.SubcomposeLayoutState.subcompose(SubcomposeLayout.kt:226) at androidx.compose.ui.layout.SubcomposeLayoutState.subcompose$ui_release(SubcomposeLayout.kt:215) at androidx.compose.ui.layout.SubcomposeLayoutState$Scope.subcompose(SubcomposeLayout.kt:466) at androidx.compose.material.ScaffoldKt$ScaffoldLayout$1$1$1.invoke(Scaffold.kt:314) at androidx.compose.material.ScaffoldKt$ScaffoldLayout$1$1$1.invoke(Scaffold.kt:241) at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:68) at androidx.compose.ui.layout.SubcomposeLayoutState$createMeasurePolicy$1$measure$1.placeChildren(SubcomposeLayout.kt:357) at androidx.compose.ui.node.LayoutNode$layoutChildren$1.invoke(LayoutNode.kt:925) at androidx.compose.ui.node.LayoutNode$layoutChildren$1.invoke(LayoutNode.kt:915) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:128) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:75) at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release(OwnerSnapshotObserver.kt:56) at androidx.compose.ui.node.LayoutNode.layoutChildren$ui_release(LayoutNode.kt:915) at androidx.compose.ui.node.LayoutNode.onNodePlaced$ui_release(LayoutNode.kt:901) at androidx.compose.ui.node.InnerPlaceable.placeAt-f8xVGno(InnerPlaceable.kt:94) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:370) at androidx.compose.ui.node.OuterMeasurablePlaceable.placeAt-f8xVGno(OuterMeasurablePlaceable.kt:149) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:370) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:203) at androidx.compose.foundation.layout.BoxKt.placeInBox(Box.kt:186) at androidx.compose.foundation.layout.BoxKt.access$placeInBox(Box.kt:1) at androidx.compose.foundation.layout.BoxKt$boxMeasurePolicy$1$measure$2.invoke(Box.kt:126) at androidx.compose.foundation.layout.BoxKt$boxMeasurePolicy$1$measure$2.invoke(Box.kt:125) at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:68) at androidx.compose.ui.node.LayoutNode$layoutChildren$1.invoke(LayoutNode.kt:925) at androidx.compose.ui.node.LayoutNode$layoutChildren$1.invoke(LayoutNode.kt:915) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:128) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:75) at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release(OwnerSnapshotObserver.kt:56) at androidx.compose.ui.node.LayoutNode.layoutChildren$ui_release(LayoutNode.kt:915) at androidx.compose.ui.node.LayoutNode.onNodePlaced$ui_release(LayoutNode.kt:901) at androidx.compose.ui.node.InnerPlaceable.placeAt-f8xVGno(InnerPlaceable.kt:94) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:370) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:203) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$measure$1$1.placeChildren(DelegatingLayoutNodeWrapper.kt:123) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt-f8xVGno(DelegatingLayoutNodeWrapper.kt:111) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:370) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:203) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$measure$1$1.placeChildren(DelegatingLayoutNodeWrapper.kt:123) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt-f8xVGno(DelegatingLayoutNodeWrapper.kt:111) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.placeWithLayer(Placeable.kt:393) at androidx.compose.ui.layout.Placeable$PlacementScope.placeWithLayer$default(Placeable.kt:266) at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier$measure$1.invoke(GraphicsLayerModifier.kt:221) at androidx.compose.ui.graphics.SimpleGraphicsLayerModifier$measure$1.invoke(GraphicsLayerModifier.kt:220) at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:68) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt-f8xVGno(DelegatingLayoutNodeWrapper.kt:111) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:370) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:203) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$measure$1$1.placeChildren(DelegatingLayoutNodeWrapper.kt:123) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt-f8xVGno(DelegatingLayoutNodeWrapper.kt:111) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.placeWithLayer-aW-9-wM(Placeable.kt:396) at androidx.compose.ui.node.OuterMeasurablePlaceable.placeAt-f8xVGno(OuterMeasurablePlaceable.kt:151) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.placeRelativeWithLayer(Placeable.kt:385) at androidx.compose.ui.layout.Placeable$PlacementScope.placeRelativeWithLayer$default(Placeable.kt:246) at androidx.compose.ui.layout.RootMeasurePolicy$measure$2.invoke(RootMeasurePolicy.kt:43) at androidx.compose.ui.layout.RootMeasurePolicy$measure$2.invoke(RootMeasurePolicy.kt:42) at androidx.compose.ui.layout.MeasureScope$layout$1.placeChildren(MeasureScope.kt:68) at androidx.compose.ui.node.LayoutNode$layoutChildren$1.invoke(LayoutNode.kt:925) at androidx.compose.ui.node.LayoutNode$layoutChildren$1.invoke(LayoutNode.kt:915) at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:1776) at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:123) at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui_release(OwnerSnapshotObserver.kt:75) at androidx.compose.ui.node.OwnerSnapshotObserver.observeLayoutSnapshotReads$ui_release(OwnerSnapshotObserver.kt:56) at androidx.compose.ui.node.LayoutNode.layoutChildren$ui_release(LayoutNode.kt:915) at androidx.compose.ui.node.LayoutNode.onNodePlaced$ui_release(LayoutNode.kt:901) at androidx.compose.ui.node.InnerPlaceable.placeAt-f8xVGno(InnerPlaceable.kt:94) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:370) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:203) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$measure$1$1.placeChildren(DelegatingLayoutNodeWrapper.kt:123) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt-f8xVGno(DelegatingLayoutNodeWrapper.kt:111) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:370) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:203) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$measure$1$1.placeChildren(DelegatingLayoutNodeWrapper.kt:123) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt-f8xVGno(DelegatingLayoutNodeWrapper.kt:111) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:370) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50$default(Placeable.kt:203) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper$measure$1$1.placeChildren(DelegatingLayoutNodeWrapper.kt:123) at androidx.compose.ui.node.DelegatingLayoutNodeWrapper.placeAt-f8xVGno(DelegatingLayoutNodeWrapper.kt:111) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.place-70tqf50(Placeable.kt:370) at androidx.compose.ui.node.OuterMeasurablePlaceable.placeAt-f8xVGno(OuterMeasurablePlaceable.kt:149) at androidx.compose.ui.layout.Placeable.access$placeAt-f8xVGno(Placeable.kt:31) at androidx.compose.ui.layout.Placeable$PlacementScope.placeRelative(Placeable.kt:359) at androidx.compose.ui.layout.Placeable$PlacementScope.placeRelative$default(Placeable.kt:179) at androidx.compose.ui.node.LayoutNode.place$ui_release(LayoutNode.kt:803) at androidx.compose.ui.node.MeasureAndLayoutDelegate.measureAndLayout(MeasureAndLayoutDelegate.kt:213) at androidx.compose.ui.platform.AndroidComposeView.onMeasure_Original(AndroidComposeView.android.kt:547) at androidx.compose.ui.platform.AndroidComposeView.onMeasure(AndroidComposeView.android.kt) at android.view.View.measure_Original(View.java:25466) at android.view.View_Delegate.measure(View_Delegate.java:80) at android.view.View.measure(View.java:25430) at androidx.compose.ui.platform.AbstractComposeView.internalOnMeasure$ui_release(ComposeView.android.kt:278) at androidx.compose.ui.platform.AbstractComposeView.onMeasure_Original(ComposeView.android.kt:265) at androidx.compose.ui.platform.AbstractComposeView.onMeasure(ComposeView.android.kt) at android.view.View.measure_Original(View.java:25466) at android.view.View_Delegate.measure(View_Delegate.java:80) at android.view.View.measure(View.java:25430) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure_Original(View.java:25466) at android.view.View_Delegate.measure(View_Delegate.java:80) at android.view.View.measure(View.java:25430) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure_Original(View.java:25466) at android.view.View_Delegate.measure(View_Delegate.java:80) at android.view.View.measure(View.java:25430) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:735) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:481) at android.view.View.measure_Original(View.java:25466) at android.view.View_Delegate.measure(View_Delegate.java:80) at android.view.View.measure(View.java:25430) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6957) at android.widget.FrameLayout.onMeasure(FrameLayout.java:194) at android.view.View.measure_Original(View.java:25466) at android.view.View_Delegate.measure(View_Delegate.java:80) at android.view.View.measure(View.java:25430) at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:673) at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureLayout(RenderSessionImpl.java:256) at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:368) at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:431) at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:141) at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:714) at com.android.tools.idea.rendering.RenderTask.lambda$inflate$7(RenderTask.java:870) at com.android.tools.idea.rendering.RenderExecutor$runAsyncActionWithTimeout$2.run(RenderExecutor.kt:187) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)

JakeWharton commented 3 years ago

Just a heads-up that I suspect this will never be fixed (it's not really possible to fix) and you should probably migrate to java.time instead per the README.

thegarlynch commented 3 years ago

Heads up, I just figure out that by adding AndroidThreeTen.init(LocalContext.current) It is now fixed by newest Android Arctic. Last month i tried this, it doesn't work.

Thank you Jack.