skrape.it 错误 java.lang.NoClassDefFoundError

问题描述 投票:0回答:1

我对 skrape.it 很陌生,尝试用它做一个简单的请求。

使用

HttpFetcher
时,一旦
response
块出现,我就会收到以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: io/ktor/client/features/HttpTimeout

我写的函数是这样的:

fun getDocumentByUrl(urlToScrape: String) = skrape(HttpFetcher) {
    request {
        url = urlToScrape
        timeout = 10000
    }
    response {
        htmlDocument {
            div(".title_table_routenliste") { findAll {}}
        }
    }
}

如果没有

response
块,请求本身就可以正常工作。

在我的依赖项中,我添加了这两行:

implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("it.skrape:skrapeit:1.2.2")

我做错了什么?

kotlin ktor-client
1个回答
0
投票

您必须使用 desugar jdk lib 来修复旧版 Android api 中的此问题 基于此文档

android {
    defaultConfig {
        // Required when setting minSdkVersion to 20 or lower
        multiDexEnabled = true
    }

    compileOptions {
        // Flag to enable support for the new language APIs

        // For AGP 4.1+
        isCoreLibraryDesugaringEnabled = true
        // For AGP 4.0
        // coreLibraryDesugaringEnabled = true
    }
}

dependencies {
    // For AGP 7.4+
    coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.0.3")
    // For AGP 7.3
    // coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.2.3")
    // For AGP 4.0 to 7.2
    // coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.1.9")
}
© www.soinside.com 2019 - 2024. All rights reserved.