在我用 Kotlin 开发的 Android 应用程序中,我无法使调试器在具有挂起功能的动态功能中在运行时设置的断点处停止。如果我在启动应用程序之前设置断点,它会起作用,但是当我尝试在运行时设置相同的断点时,它不会起作用,调试器只是继续跳过断点。我还检查了断点选项中的“全部暂停”,但无济于事,调试器仍然跳过断点。这是一个非常烦人的情况,因为每次我需要在挂起函数中的特定行暂停执行时,我必须首先停止应用程序,然后设置断点,然后重新启动应用程序。只有在这种情况下它才有效。相反,如果我在非挂起函数中设置断点,它也会在运行时起作用。任何想法?
我更新了以下库:
- kotlin.reflect to 1.5.31
- room.paging to 2.4.0-alpha05
- room.ktx to 2.4.0-alpha05
Run Code Online (Sandbox Code Playgroud)
现在,我的应用程序使用带有 Flow 和 Paging 的 Room 对象列表(实际上是我的所有 RecyclerView)的应用程序的所有功能都会崩溃,并出现以下模糊的异常:
java.lang.AbstractMethodError: abstract method "java.lang.Object androidx.paging.PagingDataDiffer.presentNewList(androidx.paging.NullPaddedList, androidx.paging.NullPaddedList, int, kotlin.jvm.functions.Function0, kotlin.coroutines.Continuation)"
at androidx.paging.PagingDataDiffer$collectFrom$2$1$1.invokeSuspend(PagingDataDiffer.kt:151)
at androidx.paging.PagingDataDiffer$collectFrom$2$1$1.invoke(Unknown Source:8)
at androidx.paging.PagingDataDiffer$collectFrom$2$1$1.invoke(Unknown Source:4)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:89)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:165)
at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1)
at androidx.paging.PagingDataDiffer$collectFrom$2$invokeSuspend$$inlined$collect$1.emit(Collect.kt:135)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:62)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt.access$emitAllImpl(Channels.kt:1)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Unknown Source:14)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:69)
at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:244)
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:161)
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:398)
at kotlinx.coroutines.CancellableContinuationImpl.completeResume(CancellableContinuationImpl.kt:514)
at kotlinx.coroutines.channels.AbstractChannel$ReceiveElement.completeResumeReceive(AbstractChannel.kt:907)
at kotlinx.coroutines.channels.ArrayChannel.offerInternal(ArrayChannel.kt:83)
at kotlinx.coroutines.channels.AbstractSendChannel.send(AbstractChannel.kt:134)
at androidx.paging.PageFetcherSnapshot.doInitialLoad(PageFetcherSnapshot.kt:318)
at androidx.paging.PageFetcherSnapshot.access$doInitialLoad(PageFetcherSnapshot.kt:55)
at androidx.paging.PageFetcherSnapshot$doInitialLoad$1.invokeSuspend(Unknown …Run Code Online (Sandbox Code Playgroud) 我已经阅读了很多关于如何自定义视图颜色的帖子,但没有关于在 iOS 11.x 或之前版本中检索标准控件(如导航栏、状态栏和标签栏)的系统颜色的内容。UIColor 类有 3 种系统颜色,但它们非常无用。例如,调用 UINavigationBar.appearance() 没有什么帮助,因为它可能会返回默认浅色方案的“清晰”颜色,以防应用程序 plist 中没有定义任何内容。那么为什么 Apple 不提供一种方法来像其他人那样以编程方式获取系统颜色(对于 Windows 和 Android)?有人知道在哪里可以找到它们吗?提前发送。
在其他现代编程语言中,当父类具有多个构造函数时,可以初始化只读属性,而无需重复代码。但 C# 似乎有一个相当烦人的限制。例如我有以下 C# 类:
class MyClass
{
string? str1 { get; init; }
string? str2 { get; init; }
public MyClass(string s1)
{
this.str1 = s1;
this.str2 = null;
}
public MyClass(string s1, string s2)
{
this.str1 = s1;
this.str2 = s2;
}
}
Run Code Online (Sandbox Code Playgroud)
可以修改构造函数来部分解决问题,如以下代码所示:
class MyClass
{
string? str1 { get; init; }
string? str2 { get; init; }
public MyClass(string s1): this(s1, null) { }
public MyClass(string s1, string s2)
{
this.str1 = s1;
this.str2 = s2; …Run Code Online (Sandbox Code Playgroud)