gradle Android:编译调试Kotlin失败,出现java.lang.ClassCastException异常

lkaoscv7  于 2023-01-26  发布在  Android
关注(0)|答案(1)|浏览(299)

我遇到了一个奇怪的问题时,建立我的android项目。compileDebugKotlin任务失败与java.lang.ClassCastException,而且它引用了一些内部的Kotlin类。我也不能确定到底是什么导致了这个问题。我不知道如何处理这种问题。我唯一想到的是可能有一些condradictory gradle依赖项。但所有的应用程序模块build.gradle文件中的依赖关系是最新的,对我的项目至关重要。请评论,如果你有任何线索,这可能是解决。

java.lang.ClassCastException: class org.jetbrains.kotlin.psi.KtSuperTypeCallEntry cannot be cast to class org.jetbrains.kotlin.psi.KtCallExpression (org.jetbrains.kotlin.psi.KtSuperTypeCallEntry and org.jetbrains.kotlin.psi.KtCallExpression are in unnamed module of loader 'app')
    at androidx.compose.compiler.plugins.kotlin.ComposeDiagnosticSuppressor.isSuppressed(ComposeDiagnosticSuppressor.kt:64)
    at org.jetbrains.kotlin.resolve.diagnostics.BindingContextSuppressCache.isSuppressedByExtension(KotlinSuppressCache.kt:241)
    at org.jetbrains.kotlin.resolve.diagnostics.KotlinSuppressCache.isSuppressed(KotlinSuppressCache.kt:69)
    at org.jetbrains.kotlin.resolve.diagnostics.KotlinSuppressCache.access$isSuppressed(KotlinSuppressCache.kt:43)
    at org.jetbrains.kotlin.resolve.diagnostics.KotlinSuppressCache$filter$1.invoke(KotlinSuppressCache.kt:50)
    at org.jetbrains.kotlin.resolve.diagnostics.KotlinSuppressCache$filter$1.invoke(KotlinSuppressCache.kt:49)
    at kotlin.collections.CollectionsKt___CollectionsKt.filter(_Collections.kt:3557)
    at org.jetbrains.kotlin.resolve.diagnostics.DiagnosticsWithSuppression.all(DiagnosticsWithSuppression.java:57)
    at org.jetbrains.kotlin.resolve.diagnostics.MutableDiagnosticsWithSuppression.all(MutableDiagnosticsWithSuppression.kt:47)
    at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport$Companion.reportDiagnostics(AnalyzerWithCompilerReport.kt:157)
    at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport$Companion.reportDiagnostics(AnalyzerWithCompilerReport.kt:165)
    at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:120)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:253)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:100)
    at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:58)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:170)
    at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
    at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
    at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:434)
    at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:120)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:357)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally$default(IncrementalCompilerRunner.kt:299)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl$rebuild(IncrementalCompilerRunner.kt:118)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:169)
    at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:80)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:622)
    at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:100)
    at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1713)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
    at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834)

我的gradle依赖项:

implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'com.google.android.play:core:1.10.2'
    //implementation 'com.google.code.gson:gson:2.8.6'

    // Compose
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation "androidx.compose.foundation:foundation:$compose_version"
    implementation "androidx.compose.foundation:foundation-layout:$compose_version"
    implementation 'androidx.activity:activity-compose:1.4.0'
    implementation "org.jetbrains.kotlin:kotlin-reflect:1.6.10"
    // Material Design
    implementation "androidx.compose.material:material:$compose_version"
    // Integration with ViewModels
    implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0'
    implementation "androidx.navigation:navigation-compose:2.4.0-rc01"
    implementation 'androidx.navigation:navigation-runtime-ktx:2.4.0-rc01'
    implementation "androidx.compose.animation:animation:$compose_version"
    // Coil for Jetpack Compose
    implementation "io.coil-kt:coil-compose:1.3.0"
    implementation "com.google.accompanist:accompanist-systemuicontroller:0.17.0"
    // Material Icons
    implementation 'androidx.compose.material:material-icons-core:1.0.5'
    implementation 'androidx.compose.material:material-icons-extended:1.0.5'

fgw7neuy

fgw7neuy1#

在我的例子中,当我添加了调用java类的命名参数时,我得到了相同的stacktrace。没有IDE警告,stacktrace也没有指向它。撤消命名参数不会再给我这个错误。

相关问题