Как исправить classnotfoundexception: не нашел класс "io.ktor.client.plugins.httptimeout"?Android

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Как исправить classnotfoundexception: не нашел класс "io.ktor.client.plugins.httptimeout"?

Сообщение Anonymous »

Я использую Gemini и Ktor для своего проекта. Когда я загружаю модель из Gemini, мое приложение бросает это исключение, хотя объект Gemini не называется: < / p > < b r / > < p r e c l a s s = " l a n g - n o n e p r e t t y p r i n t - o v e r r i d e " > < c o d e > j a v a . l a n g . r e f l e c t . I n v o c a t i o n T a r g e t E x c e p t i o n < b r / > a t j a v a . l a n g . r e f l e c t . C o n s t r u c t o r . n e w I n s t a n c e 0 ( N a t i v e M e t h o d ) < b r / > a t j a v a . l a n g . r e f l e c t . C o n s t r u c t o r . n e w I n s t a n c e ( C o n s t r u c t o r . j a v a : 3 4 3 ) < b r / > a t a n d r o i d x . l i f e c y c l e . v i e w m o d e l . i n t e r n a l . J v m V i e w M o d e l P r o v i d e r s . c r e a t e V i e w M o d e l ( J v m V i e w M o d e l P r o v i d e r s . k t : 3 8 ) < b r / > a t a n d r o i d x . l i f e c y c l e . V i e w M o d e l P r o v i d e r $ N e w I n s t a n c e F a c t o r y . c r e a t e ( V i e w M o d e l P r o v i d e r . a n d r o i d . k t : 1 9 3 ) < b r / > a t a n d r o i d x . l i f e c y c l e . V i e w M o d e l P r o v i d e r $ A n d r o i d V i e w M o d e l F a c t o r y . c r e a t e ( V i e w M o d e l P r o v i d e r . a n d r o i d . k t : 3 1 7 ) < b r / > a t a n d r o i d x . l i f e c y c l e . V i e w M o d e l P r o v i d e r $ A n d r o i d V i e w M o d e l F a c t o r y . c r e a t e ( V i e w M o d e l P r o v i d e r . a n d r o i d . k t : 2 9 9 ) < b r / > a t a n d r o i d x . l i f e c y c l e . V i e w M o d e l P r o v i d e r $ A n d r o i d V i e w M o d e l F a c t o r y . c r e a t e ( V i e w M o d e l P r o v i d e r . a n d r o i d . k t : 2 7 3 ) < b r / > a t a n d r o i d x . l i f e c y c l e . S a v e d S t a t e V i e w M o d e l F a c t o r y . c r e a t e ( S a v e d S t a t e V i e w M o d e l F a c t o r y . k t : 1 2 8 ) < b r / > a t d a g g e r . h i l t . a n d r o i d . i n t e r n a l . l i f e c y c l e . H i l t V i e w M o d e l F a c t o r y . c r e a t e ( H i l t V i e w M o d e l F a c t o r y . j a v a : 1 7 2 ) < b r / > a t a n d r o i d x . l i f e c y c l e . V i e w M o d e l P r o v i d e r $ F a c t o r y . c r e a t e ( V i e w M o d e l P r o v i d e r . a n d r o i d . k t : 1 5 8 ) < b r / > a t a n d r o i d x . l i f e c y c l e . v i e w m o d e l . V i e w M o d e l P r o v i d e r I m p l _ a n d r o i d K t . c r e a t e V i e w M o d e l ( V i e w M o d e l P r o v i d e r I m p l . a n d r o i d . k t : 3 4 ) < b r / > a t a n d r o i d x . l i f e c y c l e . v i e w m o d e l . V i e w M o d e l P r o v i d e r I m p l . g e t V i e w M o d e l $ l i f e c y c l e _ v i e w m o d e l _ r e l e a s e ( V i e w M o d e l P r o v i d e r I m p l . k t : 6 5 ) < b r / > a t a n d r o i d x . l i f e c y c l e . v i e w m o d e l . V i e w M o d e l P r o v i d e r I m p l . g e t V i e w M o d e l $ l i f e c y c l e _ v i e w m o d e l _ r e l e a s e $ d e f a u l t ( V i e w M o d e l P r o v i d e r I m p l . k t : 4 7 ) < b r / > a t a n d r o i d x . l i f e c y c l e . V i e w M o d e l P r o v i d e r . g e t ( V i e w M o d e l P r o v i d e r . a n d r o i d . k t : 9 1 ) < b r / > a t a n d r o i d x . l i f e c y c l e . v i e w m o d e l . c o m p o s e . V i e w M o d e l K t _ _ V i e w M o d e l K t . g e t ( V i e w M o d e l . k t : 1 6 2 ) < b r / > a t a n d r o i d x . l i f e c y c l e . v i e w m o d e l . c o m p o s e . V i e w M o d e l K t . g e t ( U n k n o w n S o u r c e : 1 ) < b r / > a t a n d r o i d x . l i f e c y c l e . v i e w m o d e l . c o m p o s e . V i e w M o d e l K t _ _ V i e w M o d e l _ a n d r o i d K t . v i e w M o d e l ( V i e w M o d e l . a n d r o i d . k t : 1 2 4 ) < b r / > a t a n d r o i d x . l i f e c y c l e . v i e w m o d e l . c o m p o s e . V i e w M o d e l K t . v i e w M o d e l ( U n k n o w n S o u r c e : 1 ) < b r / > a t c o m . d a g . n e x w a l l e t . f e a t u r e s . c h a t . C h a t V i e w K t . C h a t S c r e e n ( C h a t V i e w . k t : 3 2 2 ) < b r / > a t c o m . d a g . n e x w a l l e t . b a s e . n a v i g a t i o n . C o m p o s a b l e S i n g l e t o n s $ D e f a u l t N a v i g a t i o n H o s t K t $ l a m b d a - 3 $ 1 . i n v o k e ( D e f a u l t N a v i g a t i o n H o s t . k t : 7 0 ) < b r / > a t c o m . d a g . n e x w a l l e t . b a s e . n a v i g a t i o n . C o m p o s a b l e S i n g l e t o n s $ D e f a u l t N a v i g a t i o n H o s t K t $ l a m b d a - 3 $ 1 . i n v o k e ( D e f a u l t N a v i g a t i o n H o s t . k t : 6 9 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . i n t e r n a l . C o m p o s a b l e L a m b d a I m p l . i n v o k e ( C o m p o s a b l e L a m b d a . j v m . k t : 1 3 9 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . i n t e r n a l . C o m p o s a b l e L a m b d a I m p l . i n v o k e ( C o m p o s a b l e L a m b d a . j v m . k t : 3 5 ) < b r / > a t a n d r o i d x . n a v i g a t i o n . c o m p o s e . N a v H o s t K t $ N a v H o s t $ 3 2 $ 1 . i n v o k e ( N a v H o s t . k t : 7 0 4 ) < b r / > a t a n d r o i d x . n a v i g a t i o n . c o m p o s e . N a v H o s t K t $ N a v H o s t $ 3 2 $ 1 . i n v o k e ( N a v H o s t . k t : 7 0 3 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . i n t e r n a l . C o m p o s a b l e L a m b d a I m p l . i n v o k e ( C o m p o s a b l e L a m b d a . j v m . k t : 1 0 9 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . i n t e r n a l . C o m p o s a b l e L a m b d a I m p l . i n v o k e ( C o m p o s a b l e L a m b d a . j v m . k t : 3 5 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . C o m p o s i t i o n L o c a l K t . C o m p o s i t i o n L o c a l P r o v i d e r ( C o m p o s i t i o n L o c a l . k t : 4 0 1 ) < b r / > a t a n d r o i d x . c o m p o s e . r u n t i m e . s a v e a b l e . S a v e a b l e S t a t e H o l d e r I m p l . S a v e a b l e S t a t e P r o v i d e r ( S a v e a b l e StateHolder.kt:85)
at androidx.navigation.compose.NavBackStackEntryProviderKt.SaveableStateProvider(NavBackStackEntryProvider.kt:65)
at androidx.navigation.compose.NavBackStackEntryProviderKt.access$SaveableStateProvider(NavBackStackEntryProvider.kt:1)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider$1.invoke(NavBackStackEntryProvider.kt:52)
at androidx.navigation.compose.NavBackStackEntryProviderKt$LocalOwnersProvider$1.invoke(NavBackStackEntryProvider.kt:51)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:380)
at androidx.navigation.compose.NavBackStackEntryProviderKt.LocalOwnersProvider(NavBackStackEntryProvider.kt:47)
at androidx.navigation.compose.NavHostKt$NavHost$32.invoke(NavHost.kt:703)
at androidx.navigation.compose.NavHostKt$NavHost$32.invoke(NavHost.kt:683)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:139)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1$5.invoke(AnimatedContent.kt:803)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1$5.invoke(AnimatedContent.kt:792)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:118)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.AnimatedVisibilityKt.AnimatedEnterExitImpl(AnimatedVisibility.kt:771)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1.invoke(AnimatedContent.kt:774)
at androidx.compose.animation.AnimatedContentKt$AnimatedContent$6$1.invoke(AnimatedContent.kt:757)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:109)
at androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.jvm.kt:35)
at androidx.compose.animation.AnimatedContentKt.AnimatedContent(AnimatedContent.kt:816)
at androidx.navigation.compose.NavHostKt.NavHost(NavHost.kt:655)
at androidx.navigation.compose.NavHostKt$NavHost$34.invoke(Unknown Source:29)
at androidx.navigation.compose.NavHostKt$NavHost$34.invoke(Unknown Source:10)
at androidx.compose.runtime.RecomposeScopeImpl.compose(RecomposeScopeImpl.kt:192)
at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2825)
at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:3116)
at androidx.compose.runtime.ComposerImpl.doCompose(Composer.kt:3607)
at androidx.compose.runtime.ComposerImpl.recompose$runtime_release(Composer.kt:3552)
at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:948)
at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:1206)
at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:132)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:616)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:585)
at androidx.compose.ui.platform.AndroidUiFrameClock$withFrameNanos$2$callback$1.doFrame(AndroidUiFrameClock.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher.performFrameDispatch(AndroidUiDispatcher.android.kt:109)
at androidx.compose.ui.platform.AndroidUiDispatcher.access$performFrameDispatch(AndroidUiDispatcher.android.kt:41)
at androidx.compose.ui.platform.AndroidUiDispatcher$dispatchCallback$1.doFrame(AndroidUiDispatcher.android.kt:69)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1299)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1309)
at android.view.Choreographer.doCallbacks(Choreographer.java:923)
at android.view.Choreographer.doFrame(Choreographer.java:847)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1283)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8762)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [androidx.compose.runtime.PausableMonotonicFrameClock@eff8fcf, androidx.compose.ui.platform.MotionDurationScaleImpl@9bb7d5c, StandaloneCoroutine{Cancelling}@62e9865, AndroidUiDispatcher@763d93a]
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Lio/ktor/client/plugins/HttpTimeout;
at io.ktor.client.engine.okhttp.OkHttpEngine.(OkHttpEngine.kt:40)
at io.ktor.client.engine.okhttp.OkHttp.create(OkHttp.kt:31)
at io.ktor.client.engine.HttpClientEngineFactory$DefaultImpls.create$default(HttpClientEngineFactory.kt:82)
at com.google.ai.client.generativeai.common.APIController.(APIController.kt:85)
at com.google.ai.client.generativeai.common.APIController.(APIController.kt:79)
at com.google.ai.client.generativeai.GenerativeModel.(GenerativeModel.kt:97)
at com.google.ai.client.generativeai.GenerativeModel.(GenerativeModel.kt:79)
at com.dag.nexwallet.features.chat.ChatVM.(ChatVM.kt:20)
... 81 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "io.ktor.client.plugins.HttpTimeout" on path: DexPathList[[zip file "/data/app/~~NRSJpgzmf_I3UfeMcT4rsg==/com.dag.nexwallet-Sq-6nPCFXHiDoLqK-_gONw==/base.apk"],nativeLibraryDirectories=[/data/app/~~NRSJpgzmf_I3UfeMcT4rsg==/com.dag.nexwallet-Sq-6nPCFXHiDoLqK-_gONw==/lib/arm64, /data/app/~~NRSJpgzmf_I3UfeMcT4rsg==/com.dag.nexwallet-Sq-6nPCFXHiDoLqK-_gONw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:259)
at java.lang.ClassLoader.loadClass(ClassLoader.java:637)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
... 89 more
< /code>
Также я называю модель таким образом: < /p>

Код: Выделить всё

private val generativeModel = GenerativeModel(
modelName = "gemini-pro",
apiKey = BuildConfig.API_KEY
)
< /code>
Моя версия KTOR - 3.1.2. и версия пакета Generativeai составляет 0.9.0.  < /p>
Здесь также моя build.gradle: < /p>
dependencies {

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.lifecycle.runtime.ktx)
implementation(libs.androidx.lifecycle.viewmodel.compose)
implementation(libs.androidx.activity.compose)
implementation(platform(libs.androidx.compose.bom))
implementation(libs.androidx.ui)
implementation(libs.androidx.ui.graphics)
implementation(libs.androidx.ui.tooling.preview)
implementation(libs.androidx.material3)
implementation(libs.firebase.vertexai)
implementation(libs.vision.internal.vkp)
testImplementation(libs.junit)

// Test dependencies with fixed versions
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2024.02.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")

//HILT
implementation(libs.androidx.hilt.navigation.fragment)
implementation(libs.androidx.hilt.navigation.compose)
implementation(libs.hilt.android)
androidTestImplementation(libs.hilt.android.testing)
testImplementation(libs.hilt.android.testing)
kaptTest(libs.hilt.android.compiler)
kaptAndroidTest(libs.hilt.android.compiler)
kapt(libs.hilt.android.compiler)
implementation(libs.androidx.hilt.work)
//Serialization
implementation(libs.kotlinx.serialization.json)

//Navigation
implementation(libs.androidx.navigation.compose)
implementation(libs.androidx.work.runtime.ktx)

//Multidex
implementation(libs.androidx.multidex)

//Network
implementation(libs.okhttp)
implementation(libs.retrofit)
implementation(libs.converter.gson)
implementation(libs.logging.interceptor)

//Datastore
implementation(libs.androidx.datastore.preferences)

//Firebase
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.auth.ktx)
implementation(libs.firebase.analytics.ktx)
implementation(libs.firebase.analytics)

//Solana
implementation(libs.mobile.wallet.adapter.clientlib.ktx)
implementation(libs.web3.solana)
implementation(libs.rpc.core)
implementation(libs.multimult)

//EncryptedSharedPreferences
implementation(libs.androidx.security.crypto)

//Coil
implementation(libs.coil.compose)
implementation(libs.coil.network.okhttp)

//Ktor
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.core.engine)
implementation(libs.ktor.client.logging)
implementation(libs.ktor.client.auth)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.client.serialization)
implementation(libs.ktor.serialization.kotlinx.json)
}
Как мне решить эту проблему?

Подробнее здесь: https://stackoverflow.com/questions/796 ... lugins-htt
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»