Ich verwende AnchoredDraggable in meinem Projekt, um Swipe Control in Compose zu implementieren. Ich verwende Compose BOM 2024.09.00 in meinem Projekt.
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
@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,
),
)
}
Warum im Debug-Modus alles gut läuft, aber beim Generieren einer signierten APK fehlschlägt Ich habe es in einem neuen Projekt versucht. Auch hier scheitert es. Es folgen die Dateien Build.gradle.kts auf Projektebene
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.kotlin.compose) apply false
}
> Task :app:compileReleaseKotlin FAILED
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:12:45 Unresolved reference 'AnchoredDraggableDefaults'.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:70:26 Cannot infer type for this parameter. Please specify it explicitly.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:70:35 Cannot infer type for this parameter. Please specify it explicitly.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:71:13 None of the following candidates is applicable:
constructor(initialValue: T, anchors: DraggableAnchors, positionalThreshold: (@ParameterName(...) Float) -> Float, velocityThreshold: () -> Float, snapAnimationSpec: AnimationSpec, decayAnimationSpec: DecayAnimationSpec, confirmValueChange: (@ParameterName(...) T) -> Boolean = ...): AnchoredDraggableState
constructor(initialValue: T, positionalThreshold: (@ParameterName(...) Float) -> Float, velocityThreshold: () -> Float, snapAnimationSpec: AnimationSpec, decayAnimationSpec: DecayAnimationSpec, confirmValueChange: (@ParameterName(...) T) -> Boolean = ...): AnchoredDraggableState
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:73:27 This foundation API is experimental and is likely to change or be removed in the future.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:74:27 This foundation API is experimental and is likely to change or be removed in the future.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:75:26 This foundation API is experimental and is likely to change or be removed in the future.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:82:28 This foundation API is experimental and is likely to change or be removed in the future.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:89:35 Unresolved reference 'settledValue'.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:90:28 Unresolved reference 'settledValue'.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:95:29 Unresolved reference 'AnchoredDraggableDefaults'.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:97:37 Cannot infer type for this parameter. Please specify it explicitly.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:97:58 None of the following candidates is applicable:
fun BigDecimal.times(other: BigDecimal): BigDecimal
fun BigInteger.times(other: BigInteger): BigInteger
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:98:29 Cannot infer type for this parameter. Please specify it explicitly.
e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:131:36 Unresolved reference 'requireOffset'.
Ich verwende AnchoredDraggable in meinem Projekt, um Swipe Control in Compose zu implementieren. Ich verwende Compose BOM 2024.09.00 in meinem Projekt. 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]@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, ), ) } [/code] Warum im Debug-Modus alles gut läuft, aber beim Generieren einer signierten APK fehlschlägt [b]Ich habe es in einem neuen Projekt versucht. Auch hier scheitert es. Es folgen die Dateien[/b] [b]Build.gradle.kts auf Projektebene[/b] [code]// Top-level build file where you can add configuration options common to all sub-projects/modules. plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.kotlin.android) apply false alias(libs.plugins.kotlin.compose) apply false } [/code] [b]App-Ebene build.gradle.kts[/b] [code] plugins { alias(libs.plugins.android.application) alias(libs.plugins.kotlin.android) alias(libs.plugins.kotlin.compose) }
// Track Text - Stays static in the center Text( text = "Swipe to Arrive", modifier = Modifier.fillMaxWidth(), textAlign = TextAlign.Center, style = MaterialTheme.typography.labelLarge, color = MaterialTheme.colorScheme.onSurfaceVariant )
[libraries] androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" } junit = { group = "junit", name = "junit", version.ref = "junit" } androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" } androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" } material = { group = "com.google.android.material", name = "material", version.ref = "material" } androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" } androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activityCompose" } androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "composeBom" } androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" } androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" } androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" } androidx-compose-ui-test-manifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } androidx-compose-ui-test-junit4 = { group = "androidx.compose.ui", name = "ui-test-junit4" } androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
[plugins] android-application = { id = "com.android.application", version.ref = "agp" } kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" } kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } [/code] Es folgt der Build-Fehler [code] > Task :app:compileReleaseKotlin FAILED e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:12:45 Unresolved reference 'AnchoredDraggableDefaults'. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:70:26 Cannot infer type for this parameter. Please specify it explicitly. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:70:35 Cannot infer type for this parameter. Please specify it explicitly. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:71:13 None of the following candidates is applicable: constructor(initialValue: T, anchors: DraggableAnchors, positionalThreshold: (@ParameterName(...) Float) -> Float, velocityThreshold: () -> Float, snapAnimationSpec: AnimationSpec, decayAnimationSpec: DecayAnimationSpec, confirmValueChange: (@ParameterName(...) T) -> Boolean = ...): AnchoredDraggableState constructor(initialValue: T, positionalThreshold: (@ParameterName(...) Float) -> Float, velocityThreshold: () -> Float, snapAnimationSpec: AnimationSpec, decayAnimationSpec: DecayAnimationSpec, confirmValueChange: (@ParameterName(...) T) -> Boolean = ...): AnchoredDraggableState e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:73:27 This foundation API is experimental and is likely to change or be removed in the future. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:74:27 This foundation API is experimental and is likely to change or be removed in the future. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:75:26 This foundation API is experimental and is likely to change or be removed in the future. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:82:28 This foundation API is experimental and is likely to change or be removed in the future. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:89:35 Unresolved reference 'settledValue'. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:90:28 Unresolved reference 'settledValue'. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:95:29 Unresolved reference 'AnchoredDraggableDefaults'. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:97:37 Cannot infer type for this parameter. Please specify it explicitly. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:97:58 None of the following candidates is applicable: fun BigDecimal.times(other: BigDecimal): BigDecimal fun BigInteger.times(other: BigInteger): BigInteger e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:98:29 Cannot infer type for this parameter. Please specify it explicitly. e: file:///D:/Projects/Android_Projects/Temp/app/src/main/java/com/yegoglobal/testswipe/MyFile.kt:131:36 Unresolved reference 'requireOffset'. [/code]
Ich verwende AnchoredDraggable in meinem Projekt, um Swipe Control in Compose zu implementieren. Ich verwende Compose BOM 2024.09.00 in meinem Projekt.
Wenn ich jetzt das Projekt erstelle,...
Ich integriere das Mesibo Android SDK (Version 2.7.19) in meine Kotlin-Anwendung. Ich muss die Mesibo.MessageListener-Schnittstelle implementieren, um Echtzeitnachrichten zu empfangen, aber es tritt...
Ich integriere das Mesibo Android SDK (Version 2.7.19) in meine Kotlin-Anwendung. Ich muss die Mesibo.MessageListener-Schnittstelle implementieren, um Echtzeitnachrichten zu empfangen, aber es tritt...
Ich arbeite an einer iOS-App mit Swift und nutze OSLog für die Protokollierung von Debug-Informationen während der Entwicklung. Ich habe OSLog wie folgt verwendet:
import OSLog
Threads A, B, C erledigen separate Arbeiten (zwischen ihnen ist keine Synchronisation erforderlich).int a = 0;
int b = 0;
int c = 0;
std::atomic_int D_dependencies{ 3 };