I am using anchoredDraggable in my project to implement Swipe Control in Compose. I am using Compose BOM 2024.09.00 in my project.
Now when i build the project, it builds well and launched the app from android studio. But when i am generating signed apk, it fails and throw me error Unresolved reference 'AnchoredDraggableDefaults. Why ?
I am using this in code as
@OptIn(ExperimentalFoundationApi::class)
@Composable
fun someFunction(){
val swipeState = remember {
AnchoredDraggableState(
initialValue = false,
anchors = DraggableAnchors {
false at 0f
true at endPx
}
)
}
Box(
modifier = Modifier
.offset {
// Safety check to ensure offset is read only after layout/initialization
val offset = try {
swipeState.requireOffset()
} catch (e: Exception) {
0f
}
IntOffset(offset.roundToInt(), 0)
}
.size(handleSize)
.padding(4.dp)
.clip(CircleShape)
.background(MaterialTheme.colorScheme.primary)
.anchoredDraggable(
state = swipeState,
orientation = Orientation.Horizontal,
flingBehavior = flingBehavior,
),
contentAlignment = Alignment.Center
){
//some code
}
val flingBehavior = AnchoredDraggableDefaults.flingBehavior(
state = swipeState,
positionalThreshold = { distance -> distance * 0.5f },
animationSpec = spring(
dampingRatio = Spring.DampingRatioLowBouncy,
stiffness = Spring.StiffnessLow
)
)
}
Why everything runs fine in debug mode but when generating signed apk, it failes