gpt4 book ai didi

android - 将分页库从 3.0.0-alpha10 更新到 3.0.0-alpha12 时出现运行时错误

转载 作者:行者123 更新时间:2023-12-04 14:09:05 24 4
gpt4 key购买 nike

我使用分页 3.0.0-alpha10 创建了我的 pagingSource 类,它可以工作,但是当我将版本更改为 3.0.0-alpha12 时,我收到了这个错误这是运行时异常:

java.lang.AbstractMethodError: abstract method "java.lang.Object androidx.paging.PagingDataDiffer.presentNewList(androidx.paging.NullPaddedList, androidx.paging.NullPaddedList, androidx.paging.CombinedLoadStates, int, kotlin.jvm.functions.Function0, kotlin.coroutines.Continuation)"
at androidx.paging.PagingDataDiffer$collectFrom$2$invokeSuspend$$inlined$collect$1$lambda$1.invokeSuspend(PagingDataDiffer.kt:136)
at androidx.paging.PagingDataDiffer$collectFrom$2$invokeSuspend$$inlined$collect$1$lambda$1.invoke(Unknown Source:10)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturn(Undispatched.kt:91)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.withContext(Builders.common.kt:161)
at kotlinx.coroutines.BuildersKt.withContext(Unknown Source:1)
at androidx.paging.PagingDataDiffer$collectFrom$2$invokeSuspend$$inlined$collect$1.emit(Collect.kt:133)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt.emitAllImpl$FlowKt__ChannelsKt(Channels.kt:61)
at kotlinx.coroutines.flow.FlowKt__ChannelsKt$emitAllImpl$1.invokeSuspend(Unknown Source:11)
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:236)
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:161)
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:362)
at kotlinx.coroutines.CancellableContinuationImpl.completeResume(CancellableContinuationImpl.kt:479)
at kotlinx.coroutines.channels.AbstractChannel$ReceiveElement.completeResumeReceive(AbstractChannel.kt:899)
at kotlinx.coroutines.channels.ArrayChannel.offerInternal(ArrayChannel.kt:84)
at kotlinx.coroutines.channels.AbstractSendChannel.send(AbstractChannel.kt:135)
at androidx.paging.PageFetcherSnapshot.doInitialLoad(PageFetcherSnapshot.kt:315)
at androidx.paging.PageFetcherSnapshot$doInitialLoad$1.invokeSuspend(Unknown Source:11)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6543)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:810)

这是我的 PaginSource:

import androidx.paging.PagingSource
import com.example.template.api.MyApi
import com.example.template.api.responses.ChatHistoryResponse
import retrofit2.HttpException
import java.io.IOException

class ChatHistoryPagingSource
constructor(
private val myApi: MyApi,
private val search: String,
private val type: String,
private val token: String,
private val status: String,
): PagingSource<Int, ChatHistoryResponse>() {

override suspend fun load(params: LoadParams<Int>): LoadResult<Int, ChatHistoryResponse> {
val position = params.key ?: 1
return try {
val response = myApi.chatHistoryList(token, status, position, 20, type, search)
LoadResult.Page(
data = response,
prevKey = if (position == 1) null else position -1,
nextKey = if (response.isEmpty()) null else position +1
)

} catch (exception: IOException) {
LoadResult.Error(exception)
} catch (exception: HttpException) {
LoadResult.Error(exception)
}
}

}

它在以前的版本中完全可以使用,但我必须迁移到新版本。

最佳答案

很可能,您使用的 gradle 依赖项彼此不兼容。

就我而言,当我使用 androidx.room:room-paging:2.4.0-alpha05androidx.paging:paging-compose:1.0.0-alpha12 时发生异常。我通过将分页组合的版本提高到 1.0.0-alpha13 来修复它。

关于android - 将分页库从 3.0.0-alpha10 更新到 3.0.0-alpha12 时出现运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65992527/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com