Код: Выделить всё
implementation("io.ktor:ktor-serialization-kotlinx-xml:3.1.2")
implementation("io.ktor:ktor-client-cio:2.3.8")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.0")
Для создания вызовов API я использую KTOR с сериализацией XML:
Код: Выделить всё
single(named("xmlHttpClient")) {
HttpClient(CIO) {
install(ContentNegotiation) {
xml(format = XML {
xmlDeclMode = XmlDeclMode.Charset
indent = 4
autoPolymorphic = true
})
}
}
}
Код: Выделить всё
override suspend fun getAllNews(): List {
val newsResponse: NewsAPIResponse = xmlHttpClient.get(Constant.GET_ALL_NEWS).body()
newsResponse.channel.items.forEach { item ->
println("Title: ${item.title}")
println("Date: ${item.pubDate}")
}
return newsResponse.channel.items
// return emptyList()
}
Когда я запускаю приложение Android, он сбои со следующей ошибкой:
Код: Выделить всё
java.lang.NoSuchMethodError: No static method ByteChannel(Z)Lio/ktor/utils/io/ByteChannel; in class Lio/ktor/utils/io/ByteChannelKt; or its super classes (declaration of 'io.ktor.utils.io.ByteChannelKt' appears in /data/app/~~6aIPstT4YAMeqQLYjSq-oA==/com.db.mycity-Go4dcLSkzg6-8_ZtYrZySQ==/base.apk!classes24.dex)
< /code>
Вопрос < /strong> < /p>
[list]
[*] Что может вызвать этот аварий? Ktor-serialization-kotlinx-xml [/list]
Любое руководство по решению этой проблемы будет очень оценено.
Подробнее здесь: https://stackoverflow.com/questions/795 ... using-ktor
Мобильная версия