Wenn ich jetzt das Projekt erstelle, funktioniert es gut und ich habe die App über Android Studio gestartet. Aber wenn ich eine signierte APK erzeuge, schlägt es fehl und ich erhalte die Fehlermeldung Unresolved reference 'AnchoredDraggableDefaults. Warum?
Ich verwende dies im Code als
Code: Select all
@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
)
)
}
Mobile version